使用 LABjs 调用 ko.applyBinding 似乎未完成
我正在使用 LABjs 加载大量的 javascript,一切似乎都工作正常,直到最后的等待(等待确保所有内容都已加载),然后告诉淘汰赛绑定视图模型:
$LAB
.script("../lotsofJS.js")
.wait(function () {
var homepageVM = new HomepageVM();
ko.applyBindings(homepageVM);
alert("complete");
});
出于某种原因,警报从未被调用,但 firebug 没有看到任何抛出的异常或控制台输出。如果发生异常,LABjs 是否会消耗它们而不是冒泡?
我还应该提到,当单步执行 ko 和 applyBindings 时,它们都被列为对象和方法。所以它看起来不像是调用 ko 的问题,它甚至会进入 ko 缩小文件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
LABjs v2.0 引入了“调试”配置选项,将库置于调试模式,这意味着它将进度和错误输出到控制台。您必须:
1)使用 LABjs 的“调试”版本,即 LAB.src.js -OR- LAB-debug.min.js;并且
2) 打开调试模式,这是通过 $LAB.setGlobalDefaults({Debug:true}); 完成的
如果您使用的是 LAB-debug.min.js 并且要打开调试模式,并且仍然没有得到控制台输出,这将是我需要了解的错误。如果是这样,您可以在 github 问题跟踪器上提交错误吗? https://github.com/getify/LABjs/issues
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
快速浏览一下后,它确实会吞掉您的异常,除非您使用 LAB.src.js 文件(并且是 > 版本 2),否则 LAB-debug.min.js 对我不起作用。
不管怎样,抛出的错误是 jquery-tmpl 没有加载,尽管它是,但显然它需要在淘汰之前加载......之后效果很好!
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!