Commit 452414da by Arjun Singh

Kill requests for loading responses when selecting another thread. This ensures…

Kill requests for loading responses when selecting another thread. This ensures that the thread you're viewing has the right responses loaded.
parent a9009981
......@@ -26,6 +26,7 @@ if Backbone?
@thread = @discussion.get(thread_id)
@setActiveThread()
if(@main)
@main.cleanup()
@main.undelegateEvents()
@main = new DiscussionThreadView(el: $(".discussion-column"), model: @thread)
......
......@@ -71,7 +71,7 @@ class @DiscussionUtil
params["loadingCallback"].apply(params["$loading"])
else
params["$loading"].loading()
$.ajax(params).always ->
request = $.ajax(params).always ->
if $elem
$elem.removeAttr("disabled")
if params["$loading"]
......@@ -79,6 +79,7 @@ class @DiscussionUtil
params["loadedCallback"].apply(params["$loading"])
else
params["$loading"].loaded()
return request
@get: ($elem, url, data, success) ->
@safeAjax
......
......@@ -23,10 +23,15 @@ if Backbone?
@renderResponses()
@
cleanup: ->
if @responsesRequest?
@responsesRequest.abort()
renderResponses: ->
DiscussionUtil.safeAjax
@responsesRequest = DiscussionUtil.safeAjax
url: "/courses/#{$$course_id}/discussion/forum/#{@model.get('commentable_id')}/threads/#{@model.id}"
success: (data, textStatus, xhr) =>
@responsesRequest = null
@$el.find(".loading").remove()
Content.loadContentInfos(data['annotated_content_info'])
comments = new Comments(data['content']['children'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment