From: Jason Skomorowski Date: Tue, 19 Aug 2014 18:37:00 +0000 (-0400) Subject: Fix root selector for init and better document that function. X-Git-Tag: 1.0.0~39^2~7^2~6 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=19777b46905bc25b666eba4e37bacd76ffac91eb Fix root selector for init and better document that function. --- diff --git a/src/mkws-core.js b/src/mkws-core.js index 3031dd0..ddf34c9 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -550,14 +550,23 @@ mkws.pagerNext = function(tname) { } - // This function should have no side effects if run again on an operating session, even if - // the element/selector passed causes existing widgets to be reparsed: + // The second "rootsel" parameter is passed to jQuery and is a DOM node + // or a selector string you would like to constrain the search for widgets to. + // + // This function has no side effects if run again on an operating session, + // even if the element/selector passed causes existing widgets to be reparsed: + // + // (TODO: that last bit isn't true and we currently have to avoid reinitialising + // widgets, MKWS-261) // // * configuration is not regenerated // * authentication is not performed again // * autosearches are not re-run mkws.init = function(message, rootsel) { - if (message) mkws.log(message); + var greet = "MKWS initialised"; + if (rootsel) greet += " (limited to " + rootsel + ")" + if (message) greet += " :: " + message; + mkws.log(greet); // TODO: Let's remove this soon // Backwards compatibility: set new magic class names on any @@ -638,7 +647,9 @@ mkws.pagerNext = function(tname) { var then = $.now(); // If we've made no widgets, return without starting an SP session // or marking MKWS active. - if (makeWidgetsWithin(1, rootsel) === false) return false; + if (makeWidgetsWithin(1, rootsel ? $(rootsel) : undefined) === false) { + return false; + } var now = $.now(); log("walking MKWS nodes took " + (now-then) + " ms");