Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh BackboneJS on with same URL hash? [duplicate]

My current backbone application has a url:

localhost/#users

Is there a way to access localhost/#users while at the URL localhost/#users so it refreshes the page?

Currently, when I am at localhost/#users and I try

window.location.hash = #users or myBackboneRouter.navigate("users")

it does not trigger a page refresh.

like image 267
kidcapital Avatar asked Mar 29 '12 20:03

kidcapital


3 Answers

To refresh same page in backbone, you have to use

Backbone.history.loadUrl(Backbone.history.fragment);
like image 200
Fizer Khan Avatar answered Oct 16 '22 15:10

Fizer Khan


I think myBackboneRouter.navigate("users", {trigger: true}) will do what you want.

like image 44
heavi5ide Avatar answered Oct 16 '22 16:10

heavi5ide


I use these three line of codes to reload my backbone page:

router.navigate(Backbone.history.fragment, true);
Backbone.history.loadUrl( Backbone.history.fragment );
router.refresh(true);

OR Simply

Backbone.history.loadUrl(Backbone.history.fragment);
like image 2
Neel Shah Avatar answered Oct 16 '22 15:10

Neel Shah