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 \'
In order to provide a reusable snippet of code I augmented the Backbone.View with a helper method to reuse it wherever we need to reload the same page despite the Backbone router limitations.
In our app.js file or any other proper place
Backbone.View = Backbone.View.extend({
refreshPage: function(e){
if(e.target.pathname){
Backbone.history.navigate(e.target.pathname);
}
window.location.reload();
}
});
This way if we have a link such as
Some text
In our View we would just need to bind the click event to that callback to leverage the refresh page feature, as far as the refreshPage helper will be available through the prototype chain
events: {
'click #whateverId': 'refreshPage',
}
As far as we don't need to change the "a tag" it's a cleaner solution that will save some boilerplate coding
Hope it helps