It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Detecting whether events have been cancelled?

Detecting whether events have been cancelled?

Postby nottRobin on Tue Apr 08, 2008 9:18 am

I'm new at this forum. Hello everyone!

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.
nottRobin
 
Posts: 3
Joined: Fri Apr 04, 2008 9:22 am

Who is online

Users browsing this forum: No registered users and 7 guests