我有一个Group模型,它将一个json feed拉入一个数组,然后它假设将它呈现给组模板。
我的模型看起来像这样:
Mdm.Group = Ember.Object.extend(); // Creating new model class
Mdm.Group.reopenClass({
all: function() {
return $.getJSON("http://localhost:3000/1/organizations/1/groups?format=jsonp&callback=?").then(function(response) {
var groups = [];
response.groups.forEach( function (group) {
groups.push(Mdm.Group.create(group));
});
return groups;
});
}
});
我的GroupsRoute:
Mdm.GroupsRoute = Ember.Route.extend({
model: function() {
return Mdm.Group.all();
}
});
应用程序正在检索json。检查器中的网络选项卡可以完美地加载每条记录,而不是将其吐出来。
在控制台中,我收到以下错误:
Uncaught SyntaxError: Unexpected token : groups:1
Error while loading route:
Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
application.js:12147
(anonymous function) application.js:12147
Ember.Router.reopenClass.defaultFailureHandler.setup application.js:36146
failure application.js:35559
(anonymous function) application.js:35621
(anonymous function) application.js:1193
fire application.js:1038
self.fireWith application.js:1149
(anonymous function) application.js:1200
fire application.js:1038
self.fireWith application.js:1149
(anonymous function) application.js:1200
fire application.js:1038
self.fireWith application.js:1149
done application.js:8077
script.onload.script.onreadystatechange application.js:8330
Uncaught #<Object> application.js:36149
(anonymous function)
我知道大部分内容毫无意义,但如果有人见过这个,我会感激任何反馈。