tags:

views:

54

answers:

3

I'm doing this:

$("#bcdialog").dialog({
        resizable: true,
        height: 400,
        width: 600,
        modal: true,
        autoOpen: false,
        buttons: {
        'cancel': function() { $(this).dialog('close'); } 
        'save': function() { $("#bcdialog form").submit(); }
        }
    });

I would like to know if it is possible to use this for the save function instead of #bcdialog form

A: 

$(this) points to a div and there's no .submit() function for a div, so you cannot replace it.

Darin Dimitrov
+4  A: 

Perhaps giving it context of this will work, you'd still need to specify the form part, but giving it context makes it specific to the selector you've specified and you don't have to hard code the element id.

$("#bcdialog").dialog({
        resizable: true,
        height: 400,
        width: 600,
        modal: true,
        autoOpen: false,
        buttons: {
        'cancel': function() { $(this).dialog('close'); } 
        'save': function() { $("form",this).submit(); }
        }
    });

:-)

ILMV
it works, i just have to wait for 7 minutes until i can accept your answer :)
Omu
Glad I could help Omu :-)
ILMV
+1  A: 

Here we go: $("form", this).submit();

Brady
That won't work, as the context argument of the selector should be the parent of the selector itself. TI should be `div > form`, not `form > div` **edit** ok, someone's changed it
ILMV
yeah sorry, I noticed I got it wrong way round and changed it.
Brady