我使用Backbone.js的代码视图部分是这样的:
var myView = Backbone.View.extend({
events: {
'focus .cell input' : "updateCurrentCell"
},
updateCurrentCell: function(event) {
console.log('updateCurrentCell called');
// Update the current cell.
}
}
Run Code Online (Sandbox Code Playgroud)
只要input元素获得焦点,就会调用该函数两次.我尝试使用打印堆栈跟踪console.trace().它显示一旦函数调用源自焦点事件而下一次从焦点开始.
我试图找出如何防止其中一个事件被解雇导致我无处可去.我怎样才能解决这个问题?