i’m new on backbone, and i need to create a view structure like this.
<header>
<nav>...</nav>
</header>
<section id="content">
here i want to dynamically render a sub-view with its own events..
</section>
<footer>...</footer>
the sub-view changes when the user click on a link on the navigation, and its always a different sub-view (the HomeView with the news or the LoginView for the authentication process, for example…)
How can i achieve this, without delegating all the events on the LayoutView?
Use the
Backbone.Router. Instead of handling the navigation link click events in a view, match theirhrefproperties up with routes.So if you have a navigation setup like this:
Your router would look something like this: