7

im using a if statement in my handlebars template. the if statement works, but when you try change the route it causes a Uncaught TypeError: Cannot call method 'unchain' of undefined.

i have recreated the error in the following jsbin

demo : http://emberjs.jsbin.com/UnUVorUn/9

code : http://emberjs.jsbin.com/UnUVorUn/9/edit

1 Answer 1

10

Your problem happens because your IsLink starts with a capital letter, there was a bug when used in a handlebars template, already fixed in 1.3.0. But if you update your ember version you will have a new problem, because ember consider a property that starts with a capital letter being a global path, so instead of sectionController.IsLink, it will lookup window.IsLink = 'teste'.

I recommend you to just update to isLink to avoid these problems:

App.SectionController = Ember.Controller.extend({
  isLink :Ember.computed.equal('model.type', 'link')
});

Template

<ul>
  {{#link-to 'index'}} index{{/link-to}}
  {{#link-to 'test'}} test{{/link-to}}
  {{#each model itemController="section"}}
    {{#if isLink}}
      <li>{{model.color}}</li>
    {{/if}}
  {{/each}}
</ul>

http://emberjs.jsbin.com/UnUVorUn/12/edit

2
  • cool should i start everything with small letters including method names ?
    – Billybonks
    Nov 30, 2013 at 18:17
  • I think just model properties is required Nov 30, 2013 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.