0
컬렉션에 대한 뷰가 있는데 컬렉션 메서드를 호출 할 때 콜렉션 제거 메서드도 호출하면 'ReferenceError : el not defined '나에게 어떤 이해가되지 않는다. 왜 컬렉션에는 엘이 필요 할까?백본 컬렉션 remove, ReferenceError : el이 정의되지 않았습니다.
호출 코드 :보기 내
try {
myAppModel=backboneApp.views.privateViews.myAppsTabView.myAppsView.views.myAppsPrivateView.collection.get(appId);
backboneApp.views.privateViews.myAppsTabView.myAppsView.views.myAppsPrivateView.remove(myAppModel);
} catch(e) {
console.log("delFromMyAppsCollection: Failed to delete app from collection e= " + e);
}
제거 방법 :
remove : function(modelToRemove) {
alert('Killing!');
console.log("MyAppsPrivateView.remove called with model: ", modelToRemove);
this.collection.remove(modelToRemove);
console.log("MyAppsPrivateView.remove collection: ", this.collection);
this._rendered = false;
}
나는 그것이 모음 /보기에서 요소를 삭제하는 더 나은 방법이 될 수있다 생각하지만, 아직도 그 이상한 것 같다 그 소장품은 엘이없는 것에 대해 불평하고 있습니다, 어떤 생각입니까?
미리 감사드립니다. 이런 경우에
,
뷰 정의 :
var MyAppsPrivateView = Backbone.View.extend({
// Reference to this collection's model.
model: PapsCatalog , // don't should be PapModel instead of a collection?
templateId: Epc2G.myAppsTemplateId,
template: jQuery('#' + this.templateId).html(),
보기 인스턴스화 :
var options = {
className : "MyAppsContainer",
uid : "myAppsPrivateView",
collection : papsCollection,
el : "#myAppsView"
};
var oMyAppsPrivateView = new MyAppsPrivateView(_.clone(options));
그렇습니다. 컬렉션에있는 각 모델의 개별 뷰를 차례로 렌더링하는 컬렉션에 대한보기가 있습니다. 제거 방법을 무시하기 때문에 문제가 발생했는지 알 수 없습니다. – orlybg