Here is a Child View - Marionette ItemView, and parent presented by Marionette CompositeView! I tried use Backbone.babysitter, but without results
var CheckboxView = Marionette.ItemView.extend({
template: JST["components-checkboxItem"],
className: "checkbox",
ui: {
"checkbox": "#checkbox-item"
},
selectAll: function () {
//do some stuff here (this method should be called from parent)
}
});
module.exports = Marionette.CompositeView.extend({
className: 'multiselect',
template: JST["components-multiselect"],
childView: CheckboxView,
childViewContainer: ".checkboxes",
events: {
"click .selectAll": "selectAll",
},
selectAll: function () {
//I need to call appropriate child method from here!!!
}
});
You should be able to invoke it like:
this.children.call("selectAll",1,2);
or
this.children.apply("selectAll",[1,2]);
from CompositeView.
You can find more info at backbone.babysitter which is what marionette is using to handle this