views:

23

answers:

3
$('form[role=form]').delegate( "input[role=submit_button]", "click", function() {
    alert( FORM.ID  ); /// ????????????
});

IMPORTANT: without use closest() or parent() ... you know, when you write $('form[role=form]') here you have the element finded ... why to search it newly ???

+3  A: 
Gaby
A: 

You cannot do whitout search it again....

alert($(this).closest("form[role=form]").attr("id"));

Arnaud F.
*"You cannot do whitout search it again"* — This is not true.
Tomalak
A: 

In that function this and $(this) will refer to input[role=submit_button] if you want a reference to the form you should save it in a variable before calling delegate so:

var myForm = $('form[role=form]');
myForm.delegate( "input[role=submit_button]", "click", function() {
    alert( myForm.attr("id")  ); /// ????????????
});
Adam