I am using backbone to build my web app.
Currently I am facing an issue whereby if I am on the home page, I am unable to refresh the same page by just clicking on the 'home' button again.
I believe that this is the limitation provided by backbone (does not reload the page if the same URL is called)
Is there any way around this? So that I can trigger a page reload when I click on the home button again i.e. call the same URL again?
You're looking for Backbone.history.loadUrl
.
From the Annotated Source:
Attempt to load the current URL fragment. If a route succeeds with a match, returns
true
. If no defined routes matches the fragment, returnsfalse
.
So, for a simple refresh link, you can add the following event to your Backbone.View
:
events: {
'click a#refresh': function() {
Backbone.history.loadUrl();
return false;
}
}