From 018b9cd172d716f7bfab37280b1f155c71018066 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Mon, 11 Aug 2014 14:48:19 +0000 Subject: [PATCH] add a init callback for calls after page load, MKWS-255 Usually we put all JS files into one page, and after the DOM is ready we call mkws init() to register other widgets. That doesn't work if requirejs load the JS files in background, then the page load event is lost. requirejs can be configured to load the MKWS javascript files in the right order, but we have to call back mkws that the last widget is loaded, and we need to init again. --- src/mkws-core.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index 3c2ff2a..c388084 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -656,8 +656,21 @@ mkws.pagerNext = function(tname) { runAutoSearches(); } }; - $(document).ready(function() { + + // callback for calls after page load, e.g. requirejs + mkws.init_widgets = function (message) { + if (message) mkws.log(message); + var widgetSelector = selectorForAllWidgets(); - if (widgetSelector && $(widgetSelector).length !== 0) init(); + if (widgetSelector && $(widgetSelector).length !== 0) { + init(); + } else { + mkws.log("no widgets found"); + } + }; + + $(document).ready(function() { + mkws.init_widgets(); }); + })(mkws.$); -- 1.7.10.4