i would like to navigate my nested view in backbone app with routes. I have next code:
var StoreRouter = Backbone.Marionette.AppRouter.extend({
appRoutes: {
'item/:name/' : 'showItem',
"item/:name/species/:speciesName/" : "showSpecies"
}
});
var StoreCtrl = Marionette.Object.extend({
showItem: function(name){
console.log("showItem");
/* execute function for show Item */
},
showSpecies: function(name, speciesName){
console.log("showSpecies");
/* execute function for show Species inside Item Layout */
}
});
So, i need to show species when route is "item/:name/species/:speciesName/" but i get only triggering showSpecies fucntion, not both. What shall i do to trigger showItem and then showSpecies functions when route is "item/:name/species/:speciesName/" ?
There is nothing brand new here. Simply call your showItem
function directly from showSpecies
.
Additionally, you could use routes
hash instead of appRoutes
and then it is possible to do so:
var StoreRouter = Backbone.Marionette.AppRouter.extend({
routes: {
'item/:name/' : 'showItem',
'item/:name/species/:speciesName/' : function(){
this.showItem();
this.showSpecies();
}
}
});