In my Backbone View, I have defined events like this:
events : {
'click .elm' : 'select',
'dblclick .elm' : 'toggle'
},
select: function(e){
e.preventDefault();
console.log('single clicked');
}
toggle : function(e){
e.preventDefault();
console.log('double clicked');
}
I have bound single and double click event listeners to same element .elm
. When I double click on this element, I get this output:
single clicked
single clicked
double clicked
Tried preventDefault()
and stopImmediatePropagation()
and that didn't solve the issue.
So, how can I prevent the single click event getting fired when I double click?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…