I’m trying to prevent a click handler from firing based on a condition inside the mousdown handler for the same element. Consider this:
var bool = true;
$('button').click(function() {
console.log('clicked');
}).mousedown(function(e) {
bool = !bool;
if ( bool ) {
// temporary prevent the click handler, how?
}
});
Is there a neat way to cross-communicate between handlers? Here is a bin: http://jsbin.com/ipovon/1/edit
This works, although, I’m not sure it’s quite the answer you were looking for. It’s basically a double click function, if you set
bool=false;initially.Update
Also, you could pull the click function out of the
mousedownlike this, if you like: