Does anyone know if this is possible?
I need to add an event to 'click' which sets a variable, but I only want the variable to be set if the 'click' event actually eventually happens (i.e. is not cancelled before or later):
Something like (using jQuery):
- Code: Select all
// Add a click event to set 'clicked' variable
aElements.bind(
'click',
function(event) {
// Set variable to true only if the event
// hasn't been cancelled already
if(!event.cancelled) {vars.clicked = true;}
// Check every 50 milliseconds
// to see if the event has been cancelled later
// if it has, set the variable to false
window.setInterval(
function() {
if(event.cancelled) {vars.clicked = false;}
},
50
)
}
)
Obviously event.cancelled doesn't exist - this is what I'm looking for a solution to. I don't mind using stuff from other JS libraries.
Ta,
Robin.


