gpt4 book ai didi

marionette - Backbone.Marionette CollectionView 当所有 itemView 都完成渲染时回调?

转载 作者:行者123 更新时间:2023-12-04 15:46:17 29 4
gpt4 key购买 nike

我正在使用 Marionette Layout .show渲染 CollectionView并想知道是否有办法检测 全部 ItemView children 已经完成了渲染?

我的代码的简化版本是:

布局

Layouts.Group = Backbone.Marionette.Layout.extend({

template: Templates.group,

...

regions: {
header: ".group-header"
details: ".group-details"
},

...

});

集合 View
Views.GroupDetail = Backbone.Marionette.CollectionView.extend({

itemView: groupDetailRow,

...

onRender: function () {

// do something here after rendering *all* groupDetailRows of information for group detail section

}

});

项目 View
Views.GroupDetailRow = Backbone.Marionette.ItemView.extend({

onRender: function () {

// single groupDetailRow of information

}

});

。展示
var details = new Views.GroupDetail();

details.show(new DV.Time.Views.GroupDetail());

我注意到文档中提到了 .done功能:
new MyCollectionView().render().done(function(){
// all of the children are now rendered. do stuff here.
});

是否可以将其与 Layout 一起使用? ?

最佳答案

您可以监听“render”事件,或在 View 上提供“onRender”回调函数。


MyView = Marionette.CollectionView.extend({

onRender: function(){
// the list of items has been rendered. do stuff here
}

});

var view = new MyView();

view.on("render", function(){
// the list of items has been rendered. do stuff here
});

https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.collectionview.md#render--onrender-event

关于marionette - Backbone.Marionette CollectionView 当所有 itemView 都完成渲染时回调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13529407/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com