Routing & redirecting with iron-router
Asked Answered
S

1

2

How does one do an official redirect to another route from a Template.event call using meteor and Iron-Router. I seem to, at least with the Dev branch run into the same error

`if (this._isRunning)                                                                                        // 174
      throw new Error('Already in a page run'); `

As an example, i have a button that on click calls Router.go('/home'); if i run this, i get the 'already in a page run' error. Anyone else routing with the router go method?

Its actually the 'this.redirect('/anotherpath')' that causes the problem. Is there way to stop the current running page run and redirect to another route?

Strickman answered 14/9, 2013 at 18:32 Comment(0)
S
12

It looks like you're working off of the dev branch. The code you were working with has been rolled back because it wasn't working properly. If you still have the issue let me know, and sorry about that!

The code below will stop the current route controller from running (stop any downstream hooks and the action method from being run) and call Router.go('/anotherpath') which will cause a new route to run.

this.redirect('/anotherpath')
Seymourseys answered 14/9, 2013 at 22:10 Comment(4)
Should i just update to the latest in the dev branch and run with it.Strickman
Sure, try it out if you're in development. Still working out some final things and updating the tests.Seymourseys
I am using the latest in the dev branch and still having the issueStrickman
I went back to 0.5.4 and i can confirm that redirecting is working as usual.Strickman

© 2022 - 2024 — McMap. All rights reserved.