I am exploring the BBCloneMail demo application for MarionetteJS, but I am not seeing how the events are triggering the rendering actions. I saw some global 'show' event here:
show: function(){
this._showAppSelector("mail");
Marionette.triggerMethod.call(this, "show");
},
But I don't see, where/how the Marionette.triggerMethod results into rendering the Mail component. I was trying to call the triggerMethod for my case, but I get a 'cannot call apply for undefined'. Why is the call above working for the BBcloneMail application.
The Application controller for my case:
MA.AppController = Marionette.Controller.extend({ initialize: function(){ _.bindAll(this, "_showGenres"); }, show: function() { if (MA.currentUser) { MA.navbar.show(new MA.Views.Items.LogoutNavbar({model: MA.currentUser})); } else { MA.navbar.show(new MA.Views.Items.LoginNavbar()); } this._showGenres(); }, _showGenres: function() { var categoryNav = new MA.Navigation.Filter({ region: MA.filter }); this.listenTo(categoryNav, "genre:selected", this._categorySelected); categoryNav.show(); MA.main.show(MA.composites.movies); }, showMovieByGenre: function(genre){ var movies = new MA.Controllers.MoviesLib(); that = this; $.when(movies.getByCategory(genre)).then(that._showMovieList); Backbone.history.navigate("#movies/genres/" + genre); }, _showMovieList: function(movieList){ var moviesLib = new MA.Controllers.MoviesLib({ region: MA.main, movies: movieList }); Marionette.triggerMethod.call(this, "show"); } });
I init the application controller in a init.js with:
app = new MA.AppController();