Browse Source

Fix regression with .always method in ajax

pull/187/head
Artur Arseniev 9 years ago
parent
commit
4140a06a4e
  1. 14
      src/storage_manager/model/RemoteStorage.js

14
src/storage_manager/model/RemoteStorage.js

@ -24,7 +24,7 @@ module.exports = Backbone.Model.extend({
for(var key in params)
fd[key] = params[key];
$.ajax({
let req = $.ajax({
url: this.get('urlStore'),
beforeSend: this.get('beforeSend'),
complete: this.get('onComplete'),
@ -32,7 +32,10 @@ module.exports = Backbone.Model.extend({
dataType: 'json',
contentType: this.get('contentTypeJson') ? 'application/json; charset=utf-8': 'x-www-form-urlencoded',
data: this.get('contentTypeJson') ? JSON.stringify(fd): fd,
}).always(() => {
});
// Assign always callback when possible
req && req.always && req.always(() => {
if (typeof clb == 'function') {
clb();
}
@ -52,7 +55,7 @@ module.exports = Backbone.Model.extend({
fd.keys = keys;
$.ajax({
let req = $.ajax({
url: this.get('urlLoad'),
beforeSend: this.get('beforeSend'),
complete: this.get('onComplete'),
@ -61,7 +64,10 @@ module.exports = Backbone.Model.extend({
method: 'GET',
}).done(d => {
result = d;
}).always((res) => {
});
// Assign always callback when possible
req && req.always && req.always((res) => {
if (typeof clb == 'function') {
clb(res);
}

Loading…
Cancel
Save