How to trigger the Backbone.Router events in Backbone.js?

倖福魔咒の 提交于 2019-11-30 03:54:36

You can use Router#navigate:

navigate router.navigate(fragment, [options])

Whenever you reach a point in your application that you'd like to save as a URL, call navigate in order to update the URL. If you wish to also call the route function, set the trigger option to true.

So, if your router is r and you want to activate the route for #/some_route, then you could:

r.navigate('some_route', { trigger: true });

Demo (open your console please): http://jsfiddle.net/ambiguous/xkZtB/

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