【问题标题】:All children has rendered in collectionview Emberjs所有子项都已在 collectionview Emberjs 中呈现
【发布时间】:2014-06-29 00:09:38
【问题描述】:

嗨,我正在尝试使用 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: ');
    }
});

【问题讨论】:

    标签: ember.js coverflow


    【解决方案1】:

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

    例子,

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-21
      • 2019-01-18
      • 1970-01-01
      • 2019-08-29
      • 2013-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多