문제

I want to start my Backbone router at a specific action sometimes, different than the one that was navigated to. How can I change it so that when I call Backbone.history.start it goes to a specific action/fragment other than the one in the URL?

Backbone.history.start
  pushState: true
  root: "/"

Maybe there's some option, or maybe there's a way for me to change the fragment before making that function call?

Thanks!

도움이 되었습니까?

해결책

Just pass "silent" option and than call "navigate":

Backbone.history.start({ silent: true });
router.navigate('test', { trigger: true });

In this case hash that was before you called Backbone.history.start will be ignored. Hash will be changed to 'test' and the same route function will be called.

다른 팁

The Backbone.history.navigate will navigate to the route in the first argument, if the second argument is true, it will also trigger the route function.

Backbone.history.navigate('users/sam', true);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top