[英]backbone “mouseleave” is fired when the “click” event is fired
When the cursor leaves a div, the mouseleave event is fired, but if I click on a button inside the div, both the mouseleave and click events fire, although my cursor is still inside the div. 当光标离开div时,将触发mouseleave事件,但是如果我单击div内的按钮,尽管我的光标仍位于div内,但mouseleave和click事件均会触发。
here is the code: 这是代码:
events: {
'mouseleave': 'test_1',
'click button': 'test_2'
},
test_1: function() {
alert('mouseleave!');
},
test_2: function() {
alert('click!');
}
When I click the botton the mouseleave alert appears. 单击底部时,将显示mouseleave警报。 Why??
为什么??
Try changing your alert
to console.log
. 尝试将
alert
更改为console.log
。 I think it's the alert in test_2 that is causing you to leave the div. 我认为是test_2中的警报导致您离开div。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.