Search code examples
javascriptknockout.jslabjs

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 wait (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.


Solution

  • 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