From 4140a06a4e8430de7d674b24337e5344c406ea1f Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 30 Jun 2017 14:37:00 +0200 Subject: [PATCH] Fix regression with .always method in ajax --- src/storage_manager/model/RemoteStorage.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/storage_manager/model/RemoteStorage.js b/src/storage_manager/model/RemoteStorage.js index 0ecf7b0217..a44e95c778 100644 --- a/src/storage_manager/model/RemoteStorage.js +++ b/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); }