I have the set up below; backbone routing does not kick in on clicking on the products or sales link
DO I have to call navigate from the view explicitly?
<script type="text/javascript">
$(function () {
var Router = Backbone.Router.extend({
routes: {
"Products": "products",
"Sales": "sales"
},
products: function () {
console.log('products');
},
sales: function () {
console.log('sales');
}
});
new Router();
Backbone.history.start();
});
</script>
And I have 2 links for products in the aspx page
<div id= "Store">
<ul>
<li><a href="#Products">Products</a> </li>
<li><a href="#Sales"> Sales</a> </li>
</ul>
</div>
The only problem I can see with your code is that
app.initis undefined, so the script crashes before hitting the router. If I simply add a stub for that method (or removeapp.init()), then the routes get triggered as you expect.See here: http://jsfiddle.net/ZnrPd/2/