I tried to use backbone with a pushstate:
$(document).ready(function(){
var App = Backbone.Router.extend({
routes: {
"/": "homepage",
"/questions": "questions"
},
homepage: function() {
console.log('why');
},
questions: function() {
console.log('this is not working?');
}
});
var the_app = new App();
$("a").click(function(ev) {
the_app.navigate( $(this).attr("href"), true);
return false;
});
Backbone.history.start({pushState: true});
})
The problem is that whenever I click a link like one of this:
<a href="/"> home </a>
<a href="/questions"> questions</a>
<a href="/justlink"> just link</a>
Location in the browser changes without reloading, but the function, associated with it and which I already defined in routes, does not executes. Any idea what have I done wrong?