I don't want to get off on a rant here, but....

Avatar

Technology, Programming, Complaints, etc.

Ember.js confusing errors and "magic" functionality

If in ember.js you're getting errors like "TypeError: Cannot call method 'unchain' of undefined" and you get them when you try to navigate away from a route to another route. The problem may be this feature which makes model properties that start with capital letters lookup on the Ember.lookup which is basically the window object, making them act like a global property.

The confusing part is it works to build the view, data is there, behavior is as expected, it just blows up when you try to leave the route. This may just be when using the property in an if block helper. 

With Go as my JSON source all my properties are coming capitalized from the server, and only one Route had this issue.

So the solution is to make the property be lower case.  This can just be a dynamic property that aliases the Uppercase to uppercase, since it's a handlebars feature, it wouldn't impact your JS code using Ember.

And credit to this Stack Overflow answer that got me to the change and the solution.

Category: emberjs js golang