tags:

views:

23

answers:

2

I have a two or more forms on my page in a row. I'm trying to hook submit event like:

$('form',someObj).submit(function(e){ 
   /* Do some stuff with ajax */ 
   return false; 
});

But always receive events only from a first (by code) form.

Also used each() function to bind event for each object, same thing..

What's wrong? Thanks!

A: 

I rewrote everything from the beginning and doesn't reproduce the bug. Hope it's just a my mistake. Anyway, thank you all for your attention.

Coyod
A: 

If someObj contains both forms this will work, however if you just want to attach to the only two forms in the page, leave the context off the selector, like this:

$('form').submit(function(e){ 
 /* Do some stuff with ajax */ 
 return false; 
});

This will search for all forms in the document, alternatively, search for forms via a class or ID, like this:

$('form.ajaxy') //forms with class="ajaxy"
$('#form1, #form2') //forms with id="form1" and id="form2"
Nick Craver