【发布时间】:2015-05-21 13:21:47
【问题描述】:
我有一个集成了 2 个第三方库、imagesLoaded 和 Isotope 的组件。
在浏览器和 cli 模式下运行测试时出现冲突的测试失败。错误是:
Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
或
TypeError: 'undefined' is not an object (evaluating 'self.$().isotope')
当我尝试在 ember 运行循环中包装回调时,它们会在 cli 模式下传递,但在浏览器模式下会失败。我似乎找不到合适的组合。这个问题似乎发生在imagesLoaded的回调中,好像我删除了那个插件,它似乎通过了。
我尝试了多种组合,但这是我最新的代码。如果有人对如何正确使用此组件中的运行循环有所了解,那将很有帮助。
handleLoad: function() {
let self = this;
Ember.run.scheduleOnce('afterRender', this, function(){
self.$().imagesLoaded( function() {
Ember.run(function() {
self.$().isotope({itemSelector: ".card-container"});
self.$().isotope('shuffle');
});
}); // imagesLoaded
}); // Ember.run
}.on('didInsertElement')
【问题讨论】:
标签: ember.js runloop imagesloaded