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.
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.$);