Commit 1d993256 by E. Kolpakov Committed by Jonathan Piacenti

Global setting for asynchronous ajax calls - to overcome firefox's strictness…

Global setting for asynchronous ajax calls - to overcome firefox's strictness about using synchronous ajax with credentials
parent a4834094
......@@ -9,6 +9,7 @@ function DiscussionCourseBlock(runtime, element) {
var hostname = testUrl.match(/^(.*:\/\/[a-z\-.]+)\//)[1];
DiscussionUtil.setBaseUrl(hostname);
DiscussionUtil.localUrls.push('user_profile');
DiscussionUtil.force_async = true;
pushState = false
}
......
......@@ -7,10 +7,8 @@ function DiscussionInlineBlock(runtime, element) {
if (testUrl.match(/^(http|https):\/\//)) {
var hostname = testUrl.match(/^(.*:\/\/[a-z0-9:\-.]+)\//)[1];
DiscussionUtil.setBaseUrl(hostname);
DiscussionUtil.force_async = true;
}
new DiscussionModuleView({
el: el,
async_thread_views: true
});
new DiscussionModuleView({ el: el });
}
......@@ -18,6 +18,8 @@ class @DiscussionUtil
@localUrls: []
@force_async = false
@getTemplate: (id) ->
$("script##{id}").html()
......@@ -165,6 +167,9 @@ class @DiscussionUtil
else
params["$loading"].loading(params["takeFocus"])
if @force_async
params["async"] = true
request = $.ajax(params).always ->
if $elem
$elem.removeAttr("disabled")
......
......@@ -22,8 +22,6 @@ if Backbone?
if @mode not in ["tab", "inline"]
throw new Error("invalid mode: " + @mode)
@async_thread_views = if options.async_thread_views? then options.async_thread_views else false
# Quick fix to have an actual model when we're receiving new models from
# the server.
@model.collection.on "reset", (collection) =>
......@@ -233,7 +231,7 @@ if Backbone?
renderResponseToList: (response, listSelector, options) =>
response.set('thread', @model)
view = new ThreadResponseView($.extend({model: response, async: @async_thread_views}, options))
view = new ThreadResponseView($.extend({model: response}, options))
view.on "comment:add", @addComment
view.on "comment:endorse", @endorseThread
view.render()
......
......@@ -87,7 +87,9 @@ if Backbone?
url: url
type: "POST"
dataType: 'json'
async: false # TODO when the rest of the stuff below is made to work properly..
# TODO when the rest of the stuff below is made to work properly..
# Note it can be forced to true on global basis via DiscussionUtils.force_async
async: false
data:
thread_type: thread_type
title: title
......
......@@ -12,7 +12,6 @@ if Backbone?
initialize: (options) ->
@collapseComments = options.collapseComments
@async = if options.async? then options.async else false;
@createShowView()
renderTemplate: ->
......@@ -200,7 +199,9 @@ if Backbone?
url: url
type: "POST"
dataType: 'json'
async: @async # TODO when the rest of the stuff below is made to work properly..
# TODO when the rest of the stuff below is made to work properly..
# Note it can be forced to true on global basis via DiscussionUtils.force_async
async: false
data:
body: newBody
error: DiscussionUtil.formErrorHandler(@$(".edit-post-form-errors"))
......
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