0
votes

Using:

  • ember.js commit b2e82ae
  • ember-data.js commit 001ba0c
  • handlebars-1.0.rc.2.js

This used to work already with the latest router API, but now breaks after upgrading to latest commit. This is also the first upgrade that tells me to use rc.2 for handlebars, that may be a hint.

The linkTo helper raises an error, when parsing the todo_items template: Uncaught TypeError: Cannot call method 'slice' of undefined.

# router
App.Router.map(function() {
 this.resource('todo_items', function() {
   this.route('todo_item', {
      path: '/:todo_item_id'
    });
  });
});

App.TodoItemsRoute = Ember.Route.extend({
  model: function() {
    return App.TodoItem.find();
  }
});

# todo_items.handlebars
<ul>
  {{#each item in content}}
  <li>
    {{#linkTo todo_items.todo_item item}}{{item.title}}{{/linkTo}}
  </li>
  {{/each}}
</ul>

It makes no difference when I wrap the first argument of linkTo in quotes: linkTo "todo_items.todo_item" item, the same error occurres.

What am I doing wrong?

2

2 Answers

1
votes

I had a similar problem and it was caused by working from HEAD of ember.js. Switching to the official 1.0.0-pre.4 release solved it.

1
votes

Do you use precompiled templates ?

I use grunt-ember-templates for compiling handlebars template and I've the same bug

I've solved this problem with upgrading the handlebars version used for compiling templates.