mercredi 20 juillet 2016

Stop onclick method running with jQuery

I have a button similar to below

<button id="uniqueId" onclick="runMethod(this)">Submit</button>

What I'm trying to do is stop the runMethod from running, until after I've done a check of my own. I've tried using the stopImmediatePropagation function, but this doesn't seem to have worked. Here's my jQuery:

$j(document).on('click', '#uniqueId', function(event) {
    event.stopImmediatePropagation();
    if(condition == true) {
        // continue...
    } else {
        return false;
    }

    return false;
});

Note: runMethod basically validates the form, then triggers a submit.

Aucun commentaire:

Enregistrer un commentaire