Refresh BackboneJS on with same URL hash? [duplicate]

拥有回忆 提交于 2019-12-10 12:44:05

问题


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.


回答1:


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




回答2:


To refresh same page in backbone, you have to use

Backbone.history.loadUrl(Backbone.history.fragment);



回答3:


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);



回答4:


Why wouldn't you use

window.location.reload();

Either that or recall your view render() function..



来源:https://stackoverflow.com/questions/9932886/refresh-backbonejs-on-with-same-url-hash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!