Reverting to the previous path using MeteorJS and Iron Routing

Using the latest Meteor and Iron Routing, how do I simply "go back" to the previous route? I feel stupid, even asking, because it looks like this will be the main feature of Iron Routing.

For example, say that I went to "/ contacts" from "/ posts" and then I wanted to "go back" with my back button (not the browser button), although that does what I would like this function to do) in / contacts again because this was the last route I was on. Isn't there a one-line command to do this, like Router.back (), that I could put in the global routes file whenever this fires?

This seems to be a very common question, but I can't find anyone asking for it. If so, forgive me and please call me a link.

+3


source to share


2 answers


FooController.events({
    'click [data-action=back]' : function () {
        history.back();
      }
});

      

Sorry, I was looking for something like the above code that I entered into [InsertGlobalControllerName] Controller.Events ()



I wanted to make this a global event so that the feedback button can work across all layouts. I figured it out, thanks for the help!

+1


source


To get back to iron-router

, just use:

history.go(-1)

      

or



history.back()

      

Both are supported iron-router

.

+4


source







All Articles