Javascript 如何在一个Ember组件中包装jQuery?
我正在尝试将插件包装在一个Ember组件中。我面临的主要问题是图库中的照片列表来自API,因此它们是模型的一部分。到目前为止,我所拥有的:Javascript 如何在一个Ember组件中包装jQuery?,javascript,jquery,ember.js,Javascript,Jquery,Ember.js,我正在尝试将插件包装在一个Ember组件中。我面临的主要问题是图库中的照片列表来自API,因此它们是模型的一部分。到目前为止,我所拥有的: App.JustifiedGalleryComponent = Ember.Component.extend({ _init: function() { this.$().justifiedGallery({ rowHeight: 150, fixedHeight: false,
App.JustifiedGalleryComponent = Ember.Component.extend({
_init: function() {
this.$().justifiedGallery({
rowHeight: 150,
fixedHeight: false,
margins: 7
});
}.on('didInsertElement')
});
模板
{{#each photo in items}}
<div>
<img src={{photo.thumbUrl}} />
</div>
{{/each}}
问题不在组件中。我的模型是使用异步(余烬数据)加载照片的。因此,在路由器中,设置模型后,我必须强制Ember数据加载我的照片:
afterModel: function(model) {
return Em.RSVP.all([model.get('photos')]);
}
afterModel: function(model) {
return Em.RSVP.all([model.get('photos')]);
}