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

Loading…
Cancel
Save