在我的骨幹觀點,在initialize
功能我做的東西,如:翻譯`on`模式骨幹`event`哈希
initialize: function() {
$(this.el).on('click', '.button', function() {
$(this).fadeTo(0.5);
}
}
這似乎違背使用events
骨幹的會議。與events
散列重寫:
events: { 'click .button': 'fadeButton' },
fadeButton: function() {
$(this).fadeTo(0.5);
}
問題是內部fadeButton
的範圍的this
值不相同的使用.on()
時。使用events
散列做這件事的正確方法是什麼?
是的,我在考慮'event.target',但它違背了jQuery的哲學, – Randomblue 2011-12-29 00:34:35