You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.
I'm currently evaluating a few MV* frameworks to use for a bigger project and so far I really like Thorax so naturally I was messing around with it and trying to create the TodoMVC example step-by-step on my own.
After implementing the router I got the following error: Uncaught TypeError: Cannot call method 'apply' of undefined (thorax.js:1916)
Using the debugger it turns out that the callback argument in the route() function is undefined.
Digging deeper into the code I think I found the problem which is causing this error.
In Backbone.js (using the latest v0.9.9 in my learning project) the callback argument was omitted from the internal this.route() call (see: jashkenas/backbone@ef8e10f) because this argument is set in the route() function if it's not defined:
So I just took this line and added it to the beginning of the route() function in thorax.js:
route: function(route,name,callback){if(!callback)callback=this[name];//add a route:before event that is fired before the callback is calledreturnBackbone.Router.prototype.route.call(this,route,name,function(){this.trigger.apply(this,['route:before',name].concat(Array.prototype.slice.call(arguments)));returncallback.apply(this,arguments);});
This did the trick and the router is now working.
Can you verify that this is the solution or am I actually missing something else? :)
Cheers, Chris
The text was updated successfully, but these errors were encountered:
@ckrueger thanks for the detailed report on this one. We'll be releasing a new beta that is compatible with 0.9.9 this week and I'll make sure this fix gets in.
Hi,
I'm currently evaluating a few MV* frameworks to use for a bigger project and so far I really like Thorax so naturally I was messing around with it and trying to create the TodoMVC example step-by-step on my own.
After implementing the router I got the following error:
Uncaught TypeError: Cannot call method 'apply' of undefined (thorax.js:1916)
Using the debugger it turns out that the callback argument in the route() function is undefined.
Digging deeper into the code I think I found the problem which is causing this error.
In Backbone.js (using the latest v0.9.9 in my learning project) the callback argument was omitted from the internal this.route() call (see: jashkenas/backbone@ef8e10f) because this argument is set in the route() function if it's not defined:
So I just took this line and added it to the beginning of the route() function in thorax.js:
This did the trick and the router is now working.
Can you verify that this is the solution or am I actually missing something else? :)
Cheers, Chris
The text was updated successfully, but these errors were encountered: