0
私はコレクションのビューを持っています。私はremoveメソッドを呼び出すとコレクションのremoveメソッドも呼び出すと、 '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メソッド:
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