Myriad, Myriad Pro,
Ben Holmen

jQuery: $(‘#formID’).submit() issue

I ran across a strange conflict today while working with jQuery and a form. My form was doing nothing when I called the jQuery .submit(); function — no errors, but no submit. My code:

$('input.saveApplication').bind('click', function() {
... other code ...
$('#application').submit();
});

The issue was caused by having an element with ID ‘submit’:
<input type='submit' id='submit' value='Submit'>

Once I realized what was happening it made sense but it wasn’t immediately intuitive to me. If you have this error double check your IDs and rename as needed!

Filed under: Web Design — Ben @ 3:27 pm March 12, 2009