CompositeView和ItemView,如何处理两个视图和模板
CompositeView and ItemView, how to handle two views and templates?
我有以下CompositeView(1)
我想知道,对于MyCollection的每个模型,渲染两个模板和视图的最佳方式是什么(2)。
(1)
var MyCompositeView = Marionette.CompositeView.extend({
template: myTemplate,
itemView: myView,
collection: new MyCollection(),
initialize: function () {
this.collection.fetch();
},
appendHtml: function (collectionView, itemView) {
collectionView.$el.find('ul').append(itemView.el);
}
});
(2)
appendHtml: function (collectionView, itemView1, itemView2) {
collectionView.$el.find('ul').append(itemView1.el);
itemView.$el.append(itemView2.el);
}
实现目标的另一种方法,结果应该是一样的,就是在Marionette.ItemView
:中定义onRender funciton
Marionette.ItemView
中的代码应该如下所示:
onRender: function () {
var itemView2 = new ItemView2();
itemView2.render();
this.$el.append(itemView2.$el);
}
相关文章:
- 如何应用带过滤器的ng if来过滤记录,并在同一页面中显示两个不同的视图
- 使用应用程序状态js和视图在angular js url上传递两个参数
- 如何在Famo.us中的两个视图(不同的js文件)之间进行通信
- Dojo:在单页应用程序中交换两个不同的视图
- 主干组由两个视图组成
- jquery-mobile的列表视图中的两个弹出窗口
- 通过Ajax在两个视图模型中重新加载数据
- Can-Backbone视图在一个html元素上有两个不同的事件
- CompositeView和ItemView,如何处理两个视图和模板
- 在两个视图之间来回转换
- 如何在anular.js视图中比较两个字符串
- 如何在操作类中识别两个不同的 JSP 页面按钮?如何基于 JSP 页面视图按钮和查看全部按钮编写条件
- CouchDB,如何在一个视图中计算两个值
- 如何在两个视图相交时添加事件侦听器
- 如何使用 Angular js 计算网格视图项模板文本框值的两个文本框值
- OpenLayers 3.13:通过链接两个视图来提供绑定To的问题
- 需要在单个页面上使用角度 js 中的单独模块的两个视图
- 如何在同一场景中连接两个 Web 视图
- 两个不同视图上的两个按钮调用相同的函数 AngularJS
- 在主干.js中的两个视图上访问集合