this
ネストされたビューをレンダリングするときにコンテキストが失われるという問題があります。これが私のコードです:
Workflow.Views.Wall = Backbone.View.extend({
tagName: 'div',
id: 'wall',
className: 'row-fluid span12',
initialize: function() {
_.bindAll(this, 'render');
this.model.view = this;
},
render: function() {
this.model.stages.each(this.renderStage);
return this;
},
renderStage: function(model) {
var stageView = new Workflow.Views.Stage({ model: model });
//this is DOMWindow
this.$el.append(stageView.el);
}
});
つまり、「壁」には多くの「ステージ」があります。私のrenderStage関数でthis
は、DOMWindowです。
誰かが私のエラーを見ますか?