Calling ko.applyBinding with LABjs does not seem to complete
I am using LABjs to load in a vast amount of javascript, and all seems to be working fine, until the final w开发者_Go百科ait (which waits to make sure everything is loaded), then tells knockout to bind the view model:
$LAB
.script("../lotsofJS.js")
.wait(function () {
var homepageVM = new HomepageVM();
ko.applyBindings(homepageVM);
alert("complete");
});
For some reason the alert is never called, but firebug doesn't see any exceptions thrown or console output. Does LABjs consume exceptions if they occur and not bubble them?
I should also mention that when stepping through ko and applyBindings
are both listed as objects and methods. So it doesn't look like its a problem calling ko, and it even steps into the ko minified file.
LABjs v2.0 introduced the "Debug" config option, putting the lib into debug mode, which means it outputs progress and errors to the console. You have to:
1) use a "debug" build of LABjs, which is either LAB.src.js -OR- LAB-debug.min.js; AND
2) turn debug mode on, which is done with $LAB.setGlobalDefaults({Debug:true});
If you were using LAB-debug.min.js AND you were turning on debug mode, and still weren't getting console output, this would be a bug that I need to know about. If so, can you file a bug at the github issue tracker? https://github.com/getify/LABjs/issues
After a quick look around, it does swallow your exceptions unless you use the LAB.src.js file (and are > version 2), the LAB-debug.min.js didnt work for me.
Anyway the error getting thrown was that jquery-tmpl was not loaded, even though it was but apparently it needs to be loaded before knockout... after that works great!
精彩评论