2

我有一个 Group 模型,它将一个 json 提要拉到一个数组中,然后它假设将它呈现给 groups 模板。

我的模型如下所示:

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)

我知道其中大部分是毫无意义的,但如果有人在我之前看过这个,我会很感激任何反馈。

4

0 回答 0