ember教程入门:在'显示模型数据'中更改路由器会引发错误

时间:2014-01-11 04:55:16

标签: javascript ember.js

所以请事先原谅我,我显然对ember来说是全新的(对于JS来说也是新手。我正在通过增强的入门教程,逐行跟进,(除非我遗漏了一些东西) )当我的浏览器决定只渲染背景时。我回溯并发现它在按照此处的指示更改路由器后立即发生:http://emberjs.com/guides/getting-started/displaying-model-data/

我提交并推送到github:https://github.com/justuseapen/ember_tut_mock

^在浏览器中呈现的第一次提交很好,第二次提交被破坏了,如果你想看到差异。

这是我的控制台输出:

Uncaught ReferenceError: Todos is not defined todo.js:1
DEBUG: ------------------------------- ember.js:394
DEBUG: Ember.VERSION : 1.0.0 ember.js:394
DEBUG: Handlebars.VERSION : 1.0.0 ember.js:394
DEBUG: jQuery.VERSION : 1.10.2 ember.js:394
DEBUG: ------------------------------- ember.js:394
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Assertion failed: No model was found for 'todo' ember.js:394
(anonymous function) ember.js:394
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of 

putting them in an `actions` object (error on <Ember.Route:ember222>)
            at Object.triggerEvent
Error while loading route: 
TypeError
 ember.js:394
Uncaught TypeError: Cannot set property 'store' of undefined 

This is the router.js that breaks the code:
Todos.Router.map(function () {
  this.resource('todos', { path: '/' });
});

Todos.TodosRoute = Ember.Route.extend({
  model: function () {
    return this.store.find('todo');
  }
});

这是带夹具的模型:

Todos.Todo = DS.Model.extend({
  title: DS.attr('string'),
  isCompleted: DS.attr('boolean')
});

Todos.Todo.FIXTURES = [
 {
   id: 1,
   title: 'Learn Ember.js',
   isCompleted: true
 },
 {
   id: 2,
   title: '...',
   isCompleted: false
 },
 {
   id: 3,
   title: 'Profit!',
   isCompleted: false
 }
];

非常感谢任何想法。

1 个答案:

答案 0 :(得分:0)

这是Ember Data版本中的一个错误(可能是Ember / Ember数据)

http://emberjs.jsbin.com/OpOsIGEK/1/edit