所有的孩子都在收集的Emberjs中呈现

时间:2014-06-28 14:33:10

标签: ember.js coverflow

嗨我正在尝试使用Collectionview

在emberjs中构建Coverflow

我想我会在所有孩子都已经渲染后需要css计算,但我无法做到这一点,因为在我的情况下没有触发回叫

整个邮箱enter link description here 我的集合视图看起来像这样

App.CoverflowView = Ember.CollectionView.extend({
    items: null,
    itemSize: null,
    props: ['width', 'Width', 'left', 'Left'],
    itemWidth: null,
    itemHeight: null,
    duration: null,
    current: null,
    elementId: 'coverflow',
    createChildView: function (viewClass, attrs) {
        viewClass = App.CoverView;
        return this._super(viewClass, attrs);
    },
    onChildViewsChanged: function (obj, key) {
        console.log('check');
        var length = this.get('childViews.length');
        if (length > 0) {
            Ember.run.scheduleOnce('afterRender', this, 'childViewsDidRender');
        }
    }.observes('childViews'),
    childViewsDidRender: function () {
        console.log('childViewsDidRender - count of paragraphs: ');
    }
});

1 个答案:

答案 0 :(得分:0)

无论coverflow的需求如何,我都假设需要为每个视图触发函数。在此设置中,观察者不会为每个子视图触发属性childViews,并且乍一看相关代码我没有看到为了观察它而设置的属性。所以我提出了一个简单的解决方案,从createChildView调用函数,因为它已被覆盖,并且如果内容在某个时刻动态变化,也会继续观察childViews属性。

实施例,

http://emberjs.jsbin.com/weleqabu/1 (查看控制台)

createChildView: function(viewClass, attrs){
    viewClass = App.CoverView;
    this.onChildViewsChanged();
    return this._super(viewClass,attrs);
  }
相关问题