1

I have an external library that's calling form.submit(). No matter what I do, I can't seem to catch the event when it's called directly like that.

Example: http://jsfiddle.net/cwolves/yXsWc/

2 Answers 2

4

Instead of intercepting the event, have you tried intercepting the submit() call itself? You could do something like replace the default submit() function with one of your choosing that only submits if some flag is set. For instance:

var formElem = document.getElementById("myForm");
formElem.oldSubmit = formElem.submit;
formElem.submit = function(myFlag) {
    if (myFlag) {
        document.getElementById("myForm").oldSubmit();
    }
};
Sign up to request clarification or add additional context in comments.

Comments

0

This might be a bit hack-ish, but you could unbind the click event from that certain element, then re-bind it to work the way you want it to.

$('button').unbind('click').click(form.onsubmit);

jsFiddle

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.