Question

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?

Was it helpful?

Solution

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')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top