Added DataTables finalization callback
authorThierry Florac <thierry.florac@onf.fr>
Tue, 14 Oct 2014 14:39:01 +0200
changeset 86 aba8d4e80ea9
parent 85 1b31fa7e2ca3
child 87 d60763890622
Added DataTables finalization callback
src/ztfy/myams/resources/js/myams.js
--- a/src/ztfy/myams/resources/js/myams.js	Tue Oct 14 14:35:34 2014 +0200
+++ b/src/ztfy/myams/resources/js/myams.js	Tue Oct 14 14:39:01 2014 +0200
@@ -341,7 +341,7 @@
 	 * Copyright Andrew Davy: https://forrst.com/posts/Get_the_URL_of_the_current_javascript_file-Dst
 	 */
 	MyAMS.baseURL = (function () {
-		var script = $("script:last");
+		var script = $('script[src$="/myams.js"], script[src$="/myams.min.js"]');
 		var src = script.attr("src");
 		return src.substring(0, src.lastIndexOf('/') + 1);
 	})();
@@ -1721,7 +1721,7 @@
 							if (callback) {
 								var called = ams.getFunctionByName(callback);
 								if (typeof(called) == 'function')
-									called(element);
+									called.apply(source);
 								if (plugin.register !== false)
 									ams.plugins.enabled[name] = called;
 							} else {
@@ -2455,6 +2455,12 @@
 													}
 												}
 											}
+											var finalizers = (data.amsDatatableFinalizeCallback || '').split(/\s+/);
+											if (finalizers.length > 0) {
+												for (index in finalizers) {
+													ams.executeFunctionByName(finalizers[index], table, plugin, settings);
+												}
+											}
 										});
 								   });
 				}