diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 6d74a966d2..37cce1ada4 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -241,7 +241,8 @@ def single_thread(request, course_id, discussion_id, thread_id): 'recent_active_threads': recent_active_threads, 'trending_tags': trending_tags, 'course_id': course.id, - 'threads': threads, + 'thread_id': thread_id, + 'threads': json.dumps(threads), } return render_to_response('discussion/single_thread.html', context) diff --git a/lms/static/coffee/src/discussion/main.coffee b/lms/static/coffee/src/discussion/main.coffee index 3cf696ab96..0daa0ebdf3 100644 --- a/lms/static/coffee/src/discussion/main.coffee +++ b/lms/static/coffee/src/discussion/main.coffee @@ -8,6 +8,23 @@ class @DiscussionUser voted: (thread) -> @content_info[thread.id]['voted'] == 'up' +class @ThreadListItemView extends Backbone.View + tagName: "li" + template: _.template($("#thread-list-item-template").html()) + initialize: -> + @model.on "change", @render + render: => + @$el.html(@template(@model.toJSON())) + @ + +class @DiscussionThreadListView extends Backbone.View + render: -> + @collection.each @renderThreadListItem + renderThreadListItem: (thread) => + view = new ThreadListItemView(model: thread) + view.render() + @$el.append(view.el) + class @DiscussionThreadView extends Backbone.View events: "click .discussion-vote-up": "toggleVote" diff --git a/lms/templates/discussion/single_thread.html b/lms/templates/discussion/single_thread.html index 3024198750..59882a2443 100644 --- a/lms/templates/discussion/single_thread.html +++ b/lms/templates/discussion/single_thread.html @@ -30,9 +30,6 @@