admin管理员组

文章数量:1202580

I have a backbone application and i would require to know the router from which the current route is accessed. Is it possible?

For eg :-

I reach #/current from #/test1 and also in another instance, from #/test1.

So can i know through some way to detect the previous router hit?

Ive used :

Backbone.history.fragment

and this only gives me the current route accessed and not from which route.

I have a backbone application and i would require to know the router from which the current route is accessed. Is it possible?

For eg :-

I reach #/current from #/test1 and also in another instance, from #/test1.

So can i know through some way to detect the previous router hit?

Ive used :

Backbone.history.fragment

and this only gives me the current route accessed and not from which route.

Share Improve this question edited Sep 11, 2013 at 7:55 Gopesh 3,95011 gold badges39 silver badges53 bronze badges asked Sep 11, 2013 at 7:26 Roy M JRoy M J 6,9387 gold badges53 silver badges79 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 23

You can store your history in some array and do some manipulation with last/previous items.

var history = [];
this.listenTo(this, 'route', function (name, args) {
  history.push({
    name : name,
    args : args,
    fragment : Backbone.history.fragment
  });
  console.log(history);
});

本文标签: javascriptGet previous routerurl in backbone applicationStack Overflow