pull/8162/head
Halil İbrahim Kalkan 5 years ago
commit 8750c4c08b

@ -325,7 +325,7 @@ var abp = abp || {};
* AJAX extension for datatables *
*************************************************************************/
(function () {
datatables.createAjax = function (serverMethod, inputAction, responseCallback) {
datatables.createAjax = function (serverMethod, inputAction, responseCallback, cancelPreviousRequest) {
responseCallback = responseCallback || function(result) {
return {
recordsTotal: result.totalCount,
@ -333,10 +333,11 @@ var abp = abp || {};
data: result.items
};
}
var promise = null;
return function (requestData, callback, settings) {
var input = typeof inputAction === 'function'
? inputAction(requestData, settings)
: typeof inputAction === 'object'
: (typeof inputAction === 'object' && inputAction)
? inputAction : {};
//Paging
@ -368,7 +369,13 @@ var abp = abp || {};
}
if (callback) {
serverMethod(input).then(function (result) {
if(cancelPreviousRequest && promise && promise.jqXHR) {
promise.jqXHR.abort();
}
promise = serverMethod(input);
promise.always(function () {
promise = null;
}).then(function (result) {
callback(responseCallback(result));
});
}

Loading…
Cancel
Save