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.
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 bo开发者_运维百科tton the mouseleave alert appears. Why??
Try changing your alert
to console.log
. I think it's the alert in test_2 that is causing you to leave the div.
精彩评论