Ember.js教程:加载路径时出错

时间:2014-04-22 08:15:12

标签: javascript ember.js

我正在关注Ember.js Todo tutorial但是,我使用的是最新的版本,而不是使用本教程中推荐的版本,因为我认为最好使用最新版本的可用库。但是,当我尝试使用灯具填写数据时,我收到以下错误:

"DEBUG: -------------------------------"
"DEBUG: Ember      : 1.5.0"
"DEBUG: Ember Data : 1.0.0-beta.7.f87cba88"
"DEBUG: Handlebars : 1.3.0"
"DEBUG: jQuery     : 2.1.0"
"DEBUG: -------------------------------"
"Attempting URL transition to /"
"Transition #0: application: calling beforeModel hook"
"Transition #0: application: calling deserialize hook"
"Transition #0: application: calling afterModel hook"
"Transition #0: todos: calling beforeModel hook"
"Transition #0: todos: calling deserialize hook"
"Error while loading route: Ember.Error@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-1.5.0.js:910
Store<.modelFor@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9805
Store<.findAll@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9404
Store<.find@file:///C:/Projects/EmberTest/EmberTest/js/libs/ember-data.js:9073
Todos.TodosRoute<.model@file:///C:/Projects/EmberTest/EmberTest/js/router.js:9
/* stack trace goes on... */

这是我的application.js:

var Todos = Ember.Application.create({
    LOG_TRANSITIONS: true,
    LOG_TRANSITIONS_INTERNAL: true
});

Todos.ApplicationAdapter = DS.FixtureAdapter.extend();

router.js,这似乎是罪魁祸首(调用this.store.find('todo')时发生错误:

Todos.Router.map(function() {
    this.resource('todos', {
        path : '/'
    });
});

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

最后,我的todo.js:

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
} ];

有没有人知道可能导致此错误的原因?

0 个答案:

没有答案