Reputation: 448
Using Backbone + Marionette, how do I refresh the view in the initialize method of a CompositeView?
This is my code:
View.RegionProofUploadView = Marionette.CompositeView.extend({
template : regionProofsTpl,
tagName : "div",
className : "panel panel-default",
childView : View.ProofUploadView,
childViewContainer : "div.pieces",
});
Upvotes: 1
Views: 1802
Reputation: 36
First of all, as I understand from your comments, you need to refresh (or in other words re-render) your view not in initialize (which as other guys pointed out has no purpose), but after the change event happens on the child model.
In that case you can use marionette.js childEvents to listen for that "change" event and act on it.
View.RegionProofUploadView = Marionette.CompositeView.extend({
childEvents: {
'change:status': 'onStatusChange',
},
onStatusChange: function (model, value, options) {
this.render();
},
});
This should (in theory) re-render your composite view if child model status attribute change. Let me know if that was what you were expecting.
Upvotes: 2