vendor/assets/javascripts/brainstem/brainstem-sync.coffee in brainstem-js-0.2.1 vs vendor/assets/javascripts/brainstem/brainstem-sync.coffee in brainstem-js-0.3.0
- old
+ new
@@ -34,11 +34,11 @@
if model.paramRoot
data[model.paramRoot] = json
else
data = json
- data.include = Brainstem.Utils.extractArray("include", options).join(";")
+ data.include = Brainstem.Utils.extractArray("include", options).join(",")
data.filters = Brainstem.Utils.extractArray("filters", options).join(",")
params.data = JSON.stringify(data)
# For older servers, emulate JSON by encoding the request into an HTML-form.
if options.emulateJSON
@@ -55,21 +55,26 @@
options.beforeSend = (xhr) ->
xhr.setRequestHeader 'X-HTTP-Method-Override', type
if beforeSend
beforeSend.apply this, arguments
+ # Clear out default data for DELETE requests, fixes a firefox issue where this exception is thrown: JavaScript component does not have a method named: “available”
+ if params.type == 'DELETE'
+ params.data = null
+
# Don't process data on a non-GET request.
if params.type != 'GET' && !options.emulateJSON
params.processData = false
# If we're sending a `PATCH` request, and we're in an old Internet Explorer
# that still has ActiveX enabled by default, override jQuery to use that
# for XHR instead. Remove this line when jQuery supports `PATCH` on IE8.
if params.type == 'PATCH' && window.ActiveXObject && !(window.external && window.external.msActiveXFilteringEnabled)
params.xhr = -> new ActiveXObject("Microsoft.XMLHTTP")
- errorHandler = options.error
- options.error = (jqXHR, textStatus, errorThrown) -> base?.data?.errorInterceptor?(errorHandler, model, options, jqXHR, params)
+ if base?.data?.errorInterceptor?
+ errorHandler = options.error
+ options.error = (jqXHR, textStatus, errorThrown) -> base.data.errorInterceptor(errorHandler, model, options, jqXHR, params)
# Make the request, allowing the user to override any Ajax options.
xhr = options.xhr = Backbone.ajax(_.extend(params, options))
model.trigger 'request', model, xhr, options
xhr