我目前正忙于学习 ember.js,我想知道如何最好地使用 ember 的砌体。我找不到任何好的方法。有人有一些建议吗?
最佳答案
我对原型(prototype)进行了非常粗略的集成。下面的代码是一个很好的起点,但根据用户与内容交互的方式,还需要做更多的工作。
这假设您已经有一个工作的 ember 页面,其中有一个准备渲染的 ArrayController。
这是利用砖石的 View :
App.HomeView = Ember.View.extend({
onDidInsertElement: function() {
this.reMason();
}.on('didInsertElement'),
onWillDestroy: function() {
this.$('.masonry').masonry('destroy');
}.on('willDestroy'),
reMason: function() {
this.$('.masonry').masonry({
// masonry init options here
});
this.$('.masonry').imagesLoaded( function() {
this.$('.masonry').masonry();
}.bind(this));
}
});
这是我们渲染砌体 html 的模板
<script type="text/x-handlebars" data-template-name="homeView">
...
<div class="masonry">
{{#each}}
// render each masonry item here.
{{/each}}
</div>
...
</script>
关于ember.js - 如何将 jquery-masonry 与 ember.js 集成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21779815/