I've got the following route configuration: https://gist.github.com/chriswessels/76a64c421170095eb871
I'm getting the following error when attempting to load a route:
Exception in defer callback: TypeError: undefined is not a function
at manageLoadingIndicator (http://localhost:3000/both/router/routes.js?ef701fada29363a443a214f97988ce96ebaec025:30:10)
at RouteController.runHooks (http://localhost:3000/packages/iron_router.js?da7f2ac81c3fd9daebf49ce9a6980a54caa1dc17:843:16)
at http://localhost:3000/packages/iron_router.js?da7f2ac81c3fd9daebf49ce9a6980a54caa1dc17:2302:14
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at http://localhost:3000/packages/iron_router.js?da7f2ac81c3fd9daebf49ce9a6980a54caa1dc17:2279:12
at Utils.extend._run.withNoStopsAllowed (http://localhost:3000/packages/iron_router.js?da7f2ac81c3fd9daebf49ce9a6980a54caa1dc17:2248:21)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
It's talking about the following line, which is in a onBeforeAction hook:
function manageLoadingIndicator (pause) {
if (this.ready()) {
Session.set('loading', false);
this.next(); // THIS LINE HERE
} else {
Session.set('loading', true);
pause();
}
}
Why is this.next
undefined? Help please!
Chris
You are mixing up different versions of Iron router:
Prior to iron router 1.0, onBeforeAction
would proceed to action unless pause
(the first arg to onBeforeAction
is invoked. There is no .next()
method.
From 1.0 onwards this has been changed. pause()
is no longer passed as an argument. This is where the .next()
method replaces it.
You are evidently running on an old version of iron router, so therefore your hook should look like this:
function manageLoadingIndicator (pause) {
if (this.ready()) {
Session.set('loading', false);
} else {
Session.set('loading', true);
pause();
}
}
Once you upgrade iron router, you need to change it to this:
function manageLoadingIndicator () {
if (this.ready()) {
Session.set('loading', false);
this.next();
} else {
Session.set('loading', true);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With