开发者

backbone "mouseleave" is fired when the "click" event is fired

开发者 https://www.devze.com 2023-04-06 17:07 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消