0
我對骨幹有新意,並且有一個問題。當我認爲一個事件被解僱時,我似乎失去了「這個」的背景。我怎樣才能保留這個模型或獲得原始的「this」。這裏是一個例子:backbone.js這個上下文在事件函數中丟失了
var MyListView = MyDBView.extend({
initialize: function(options){
},
render: function() {
//stuff here. I can access this.options here
},
dialogResponseYes: function(e){
//try to get this.options and options is undefined as this has changed to another element (a button)
}
});
那麼,我該如何得到這個原始的上下文呢?
您的看法是什麼你想'這個'指向?風景? – MMM
是的。另外,我想在MyListView類中聲明所有函數都可以訪問的公共屬性。但要做到這一點,我需要能夠保持所有方法和函數的「this」相同的上下文 – jason
[在BackboneJS視圖中保持上下文]的可能重複(http://stackoverflow.com/questions/13233979/keep-context -within-backbonejs-view) – nikoshr