1

私は残り火に大きな問題を抱えています。どこかに移動するCannot set property 'type' of nullと、時々エラーが発生し、ビューがレンダリングされません。エラーは、Ember ではなく jQuery でスローされます。

something.typeアプリケーションに設定したことがありません。エラーが何であるかわかりません。ルート + コントローラー + ビューの例 (毎回発生するわけではないことを忘れないでください)。

ルーティング:this.route("channels", {path: "/channels/:only"});

ルート:

App.ChannelsRoute = Ember.Route.extend({
  model: function(params) {
    var controller = this.controllerFor("channels");
    controller.set("only", params.only);

    if (!controller.get("hasContent")) {
      return controller.updateContent();
    }
  }
});

コントローラ:

App.ChannelsController = Ember.ArrayController.extend({

  sortProperties: ["position"],
  sortAscending: true,

  hasContent: function() {
    return this.get("content").length > 0;
  }.property("@each"),

  channels_category: function() {
    return this.get("only");
  }.property("only"),

  filteredContent: function() {
    var filterType = "group";
    var filterID = 1;

    switch(this.get("only")) {
      case "primary": filterType = "group"; filterID = 1; break;
      case "secondary": filterType = "group"; filterID = 2; break;
      case "regional": filterType = "group"; filterID = 3; break;
      case "hd": filterType = "hd"; filterID = true; break;
      default: filterType = "group"; filterID = 1; break;
    }

    return this.filterProperty(filterType, filterID);
  }.property("@each", "only"),

  updateContent: function() {
    return $.getJSON(getAPIUrl("channels.json")).then(function(data){
      var channels = [];
      $.each(data.channels, function() {

        var channel = App.Channel.create({
          id: this.id,
          name: this.name,
          group: this.group,
          hd: this.hd,
          position: this.position,
          recordable: this.recordable
        });
        channels.pushObject(channel);
      });

      return channels;
    });
  }
});

多くのコントローラーで発生しています。誰かが解決策を知っていることを願っています。

4

2 に答える 2

0

jQuery で発生している場合は、AJAX 呼び出しまたは jQuery で行っている DOM 操作のいずれかで発生しています。最良のスタートは、AJAX 呼び出しをいじって、使用しているハンドルバー ヘルパーを確認することです (特に、型が宣言された入力ヘルパーがある場合)。

于 2013-10-18T19:59:44.373 に答える
0

updateContent 関数のこのバリエーションをテストできますか? チャンネル変数をコントローラーモデルに変更しました...

  updateContent: function() {
    return $.getJSON(getAPIUrl("channels.json")).then(function(data){
      var channels = this.get('model');
      $.each(data.channels, function() {

        var channel = App.Channel.create({
          id: this.id,
          name: this.name,
          group: this.group,
          hd: this.hd,
          position: this.position,
          recordable: this.recordable
        });
        channels.pushObject(channel);
      });
    });
  }
于 2013-10-18T15:37:42.617 に答える