Reputation: 18010
I want execute show code after any showing any regions. I tried:
app.Layout = Backbone.Marionette.Layout.extend({
template: "#layout-template",
regions: {
mini1: {
selector: "#mini1",
onShow: function () {
console.log("triggered!");
}
}});
app.layout.mini1.show(new view());
But the onShow function does not run. What is wrong with it?
Upvotes: 0
Views: 29
Reputation: 1018
There are 3 way of defining region in list of region:
selector
and regionType
propertiesSo when you pass object you can not specify onShow
handler. But you can do what you want if you pass extended Marionette.Region
:
var Layout = Backbone.Marionette.Layout.extend({
template: "#layout-template",
regions: {
mini1: Marionette.Region.extend({
el: "#mini1",
onShow: function () {
console.log("triggered!");
}
})
}
});
You can check this solution here: http://jsfiddle.net/2CvzR/
And documentation is here: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.region.md#custom-region-types
Upvotes: 2