Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 386d269

Browse files
committed
Use the correct version from plnkr #242
1 parent b7d75e3 commit 386d269

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

dist/angular-datatables.js

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,10 @@ angular.module('datatables.instances', [])
411411
function dtInstances($q) {
412412
var _instances = {};
413413
// Promise for fetching the last DT instance
414-
var _deferLastDTInstances = null;
414+
var _deferLastDTInstance = $q.defer();
415415
var _lastDTInstance = null;
416416
// Promise for fetching the list of DT instances
417-
var _deferDTInstances = null;
418-
var _dtInstances = null;
417+
var _deferDTInstances = $q.defer();
419418
return {
420419
register: register,
421420
getLast: getLast,
@@ -428,41 +427,34 @@ function dtInstances($q) {
428427
dtInstance.dataTable = result.dataTable;
429428

430429
_instances[dtInstance.id] = dtInstance;
431-
if (_deferLastDTInstances) {
432-
_deferLastDTInstances.resolve(dtInstance);
433-
}
434-
if (_deferDTInstances) {
435-
_deferDTInstances.resolve(_instances);
436-
}
430+
_lastDTInstance = dtInstance;
431+
432+
//previous promise
433+
_deferDTInstances.resolve(_instances);
434+
_deferLastDTInstance.resolve(_lastDTInstance);
435+
436+
//new promise
437+
_deferDTInstances = $q.defer();
438+
_deferLastDTInstance = $q.defer();
439+
440+
_deferDTInstances.resolve(_instances);
441+
_deferLastDTInstance.resolve(_lastDTInstance);
442+
437443
return dtInstance;
438444
}
439445

440446
function getLast() {
441447
var defer = $q.defer();
442-
if (!_lastDTInstance) {
443-
_deferLastDTInstances = $q.defer();
444-
_lastDTInstance = _deferLastDTInstances.promise;
445-
}
446-
_lastDTInstance.then(function(dtInstance) {
447-
defer.resolve(dtInstance);
448-
// Reset the promise
449-
_deferLastDTInstances = null;
450-
_lastDTInstance = null;
448+
_deferLastDTInstance.promise.then(function(lastInstance) {
449+
defer.resolve(lastInstance);
451450
});
452451
return defer.promise;
453452
}
454453

455454
function getList() {
456455
var defer = $q.defer();
457-
if (!_dtInstances) {
458-
_deferDTInstances = $q.defer();
459-
_dtInstances = _deferDTInstances.promise;
460-
}
461-
_dtInstances.then(function(instances) {
456+
_deferDTInstances.promise.then(function(instances) {
462457
defer.resolve(instances);
463-
// Reset the promise
464-
_deferDTInstances = null;
465-
_dtInstances = null;
466458
});
467459
return defer.promise;
468460
}

0 commit comments

Comments
 (0)