如何定义CompositeView
define(function (require) {
"use strict";
var _ = require('underscore'),
Marionette = require('backbone.marionette'),
Row = require('app/views/Dam/row'),
tpl = require('text!tpl/Dam/table.html'),
template = _.template(tpl);
return Marionette.CompositeView.extend({
tagName: "table",
className: "table table-bordered",
initialize: function (opt) {
this.ev = opt.ev;
},
childView: Row,
childViewContainer: function(){
return "tbody"
},
childViewOptions: function (model, index) {
return {
ev: this.ev
}
},
onRender: function () {
this.ev.trigger('App:Loading:Hide', true);
}
});
});
这个复合视图是Marionette.Region的孩子。我只是像region.show(new CompositeView)
那样触发它。我使用的是最新的Backbone以及Marionette。
答案 0 :(得分:1)
为任何视图定义模板
Marionette.CompositeView.extend({
tagName: "table",
template : tpl,
.....
.....
它应该有用