Answer the question
In order to leave comments, you need to log in
How to pass model to nested Marionette.CompositeView?
There is a View which is used in CompositeView
var ItemView = Marionette.LayoutView.extend({
tagName: 'tr',
template: ItemTemplate,
regions: {
footer: "#content"
},
events: {
'click td': 'showDismiss'
},
showDismiss: function () {
var EmptyV = new DismissViewComposite();
if (this.footer.hasView())
this.footer.empty();
else {
<this.footer.show(EmptyV);
}
EmptyV.render();
},
templateHelpers: function () {
var model = this.model;
var numberFunc = this.numberFormatter;
var dateFunc = this.dateFormatter;
return {
USER_NAME: model.get('USER_NAME'),
TMC_TYPE_NAME: model.get('TMC_TYPE_NAME'),
DISMISS_COUNT: model.get('D<code lang="javascript"></code>ISMISS_COUNT'),
CULTURE_NAME: model.get('CULTURE_NAME'),
DATE: dateFunc(model.get('DATE')),
};
},
var DismissViewComposite = Marionette.CompositeView.extend({
childView: new DismissView(),
childViewContainer: "tbody",
className: 'historyItem',
emptyView: EmptyView,
template: DismissTable,
});
var DismissView = Marionette.ItemView.extend({
tagName: 'tr',
template: DismissItemTemplate,
templateHelpers: function () {
var model = this.model;
var dismisses = model.get('VIEW_TMC_DISMISS_DATA');
var numberFunc = this.numberFormatter;
var dateFunc = this.dateFormatter;
return {
CLASS_TYPE: "1",
COUNT_T: 1,
ITEM_ID: 1
};
},
Answer the question
In order to leave comments, you need to log in
You need to explicitly pass the model.
var EmptyV = new DismissViewComposite({
model: this.model
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question