I'm having a problem with backbone routes and views. The views are properly rendered when I click on the link and the url is correct as well, but the problem is whenever I refresh the page, the url is still the same but the view goes back to the index view, wherein it's supposed to render the view under that route, which results to events not being properly handled.
here's the router:
var MainRouter = Backbone.Router.extend({
initialize: function() {
// homeView.render();
},
routes: {
'': 'index',
'register': 'register'
}
});
var mainRouter = new MainRouter();
router.on('route:index', function() {
if (htmlObj.hasClass('connected')) {
if (htmlObj.hasClass('present')) {
profileView.render();
}
homeView.render();
}
});
router.on('route:register', function() {
signUpView.render();
});
Backbone.history.start();
and then in the view events I set the trigger to true
Backbone.history.navigate('#/signup', {trigger: true});
So it would run the function of that specific route.
I also tried using pushState and root but it has the same problem on refresh but this time it says that page not found.
Thanks