src/pyams_skin/resources/js/myams-ajax.js
changeset 500 f08f5a2ffaa6
parent 489 63ea9a94bd47
--- a/src/pyams_skin/resources/js/myams-ajax.js	Thu Dec 20 14:15:59 2018 +0100
+++ b/src/pyams_skin/resources/js/myams-ajax.js	Thu Dec 20 18:40:36 2018 +0100
@@ -43,10 +43,11 @@
 			var defaults = {
 				async: typeof(callback) === 'function'
 			};
-			var settings = $.extend({}, defaults, options);
+			var settings = $.extend({}, defaults, options),
+				deferred = [],
+				index;
 			if (checker instanceof Array) {
-				var deferred = [];
-				for (var index = 0; index < checker.length; index++) {
+				for (index = 0; index < checker.length; index++) {
 					if (checker[index] === undefined) {
 						deferred.push(ams.getScript(source[index], {async: true}));
 					}
@@ -59,7 +60,18 @@
 					callCallbacks(false, options);
 				}
 			} else if (checker === undefined) {
-				if (typeof(source) === 'string') {
+				if (source instanceof Array) {
+					for (index = 0; index < source.length; index++) {
+						deferred.push(ams.getScript(source[index], {async: true}));
+					}
+					if (deferred.length > 0) {
+						$.when.apply($, deferred).then(function () {
+							callCallbacks(true, options);
+						});
+					} else {
+						callCallbacks(false, options);
+					}
+				} else if (typeof(source) === 'string') {
 					ams.getScript(source, function () {
 						callCallbacks(true, options);
 					}, settings);