Incase a form is not valid, I want to print a message in the browser console.
Folling code with bind works:
jQuery(document).ready(function () {
$('form').bind('submit', function () {
if ($j(this).valid() == false) {
console.log("Warning: form not valid");
};
});
});
and works as well when I replace bind by submit:
$('form').submit(function () {
But doesnt work when I use delegate:
$('body').delegate('form', 'submit', function () {
And even with live no success:
$('form').live('submit', function () {
Form is not dynamicly insertet. What could be the reason for that live and delegate don't work??
EDIT
I just found out that jquery.validate.min.js was causing the problem. Hm, but how can I prevent my own form events to be prevented?
You will have another handler either on the form
element or an ancestor between the form
and the body
which is preventing the propagation of the event, either by;
stopPropagation()
on the event objectstopImmediatePropagation()
on the event objectreturn false
'ing from the event handler.You need to find that handler, and stop it doing so. Bear in mind this may be the work of a plugin you have enabled as well.