私は残り火に大きな問題を抱えています。どこかに移動する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;
});
}
});
多くのコントローラーで発生しています。誰かが解決策を知っていることを願っています。