I'm new to Marionette (though not to Backbone), and have decided to use it to manage my routing. Suppose I have the following situation:
var AppRouterController = {
//Route to the homepage
home: function() {
//Unload the existing route, and load this one instead
},
//Route to a user profile page
user: function() {
//Unload the existing route, and load this one instead
},
//Route to a list of tasks or something
tasks: function() {
//Unload the existing route, and load this one instead
},
};
var TheRouter = new Marionette.AppRouter({
controller: new AppRouterController(),
appRoutes: {
"home": "home",
"user/:id": "user",
"tasks/:date": "tasks"
}
});
I would like for my app to load each new route dynamically, and completely remove its predecessor from the DOM (probably via an animation where, at least for a little bit, they will share screen space). I can see my app having two regions: the "navbar", and the "content" (the area where the information from a given route is rendered"):
<html>
<body>
<section region="navbar"></section>
<section region="content" id="home|user|tasks|whateverRoute"></section>
</body>
</html>
So, my DOM body would always have two children: the navbar region section, and the content region section for whatever the current active route in Marionette is. What would be the best way to manage this process in Marionette? By that I mean, only grabbing the modules in a particular route when they are needed (rather than grabbing them all on load), creating a new "content" region, and replacing the existing "content" region in a smooth manner.