當我從ArrayController中刪除項時,我不能調用未定義對象的方法'set'。不能調用未定義的餘燼的方法'集'
start: function() {
this.registerModel('listController', Ember.ArrayController.create());
this._super();
},
我的視圖看起來像,
{{#each item in marketingListCriteriaList}}
{{view Select valueBinding="item.entity" contentBinding="controller.allEntities" optionLabelPath="content.Name" optionValuePath="content.Name" }}
{{/each}}
我有觀察 .observes一個觀察者方法( 'listController。@ each.entity')
上述觀察者被調用我時使用removeObject()方法從數組控制器中刪除對象。
有沒有其他方法可以從數組中刪除對象?
entityChangeObserver: function (thisModule) {
var thisModule = this;
var criteria = thisModule.get('listController.content');
if (criteria != undefined && criteria.length > 0 && criteria[criteria.length - 1].entity != undefined) {
var presentObject = criteria[criteria.length - 1];
$.each(thisModule.get('allEntities'), function (index, item) {
if (presentObject.entity === item.Name) {
presentObject.set('allAttributes', item.Attributes);
}
});
}
}.observes('[email protected]'),
attributeChangeObserver: function (thisModule) {
var thisModule = this;
var criteria = thisModule.get('listController.content');
if (criteria != undefined && criteria.length > 0 && criteria[criteria.length - 1].attribute != undefined) {
var presentObject = criteria[criteria.length - 1];
$.each(presentObject.get('allAttributes'), function (index, item) {
if (presentObject.attribute === item.Name) {
thisModule.setDefaulsVisibility(presentObject);
if (item.Type === '1') {
presentObject.set('textVisible', true);
}
else if (item.Type === '2') {
presentObject.set('selectVisible', true);
presentObject.set('allValues', item.Values);
}
else if (item.Type === '3') {
presentObject.set('multiSelectVisible', true);
presentObject.set('allValues', item.Values);
}
else if (item.Type === '4') {
presentObject.set('dateVisible', true);
}
}
});
}
}.observes('[email protected]'),
對不起,給出了錯誤的描述。我得到的錯誤是**對被銷燬的對象**進行調用。我在觀察者中處理了未定義的異常。 – Avinash
發佈上面編輯過的觀察員觸發 – Jaime
時調用的代碼 – Avinash