Inside the confirm button callback, you could do
$(this).find('form').submit();
This will search in the dialog the button is in for a form and submit it.
Seems easier than messing with ids.
- Richard
On Wed, Dec 9, 2009 at 5:36 PM, moleculezz <[email protected]> wrote:
> Hello,
> I am trying to use dialog windows to submit forms on a page. I have
> multiple dialogs with each containing a form to submit. But I can't
> seem to get it to submit the form based on the form id.
> If you look at the "Confirm" dialog button, I put some kind of
> reference to the specified form id $('form#delete-0'), $
> ('form#delete-1'), etc..
> Mind you I'm new to jquery so I'm not very familiar with the syntax.
>
> My code is something like this:
> $(function() {
>
> var n = 0;
> $("tbody tr td a.links-members").each(function() {
>
> var dlg = $('#dialog-member-' + n).dialog({
>
> autoOpen: false,
>
> show: 'blind',
>
> hide: 'fold',
>
> width: 400,
>
> modal: true,
>
> buttons: {
>
> "Confirm": function() {
>
> $('form#delete-' + n).submit();
>
> },
>
> "Cancel": function() {
>
> $(this).dialog('close');
>
> }
>
> }});
> $('#link-member-' + n).click(function() {
> dlg.dialog("open");
> return false;
> });
> n++;
> });
> });
>
> HTML Example:
> <div id="dialog-member-0">
> <form action="http://localhost/member" method="post" id="delete-0"
> name="del" class="delete-member">
> <input type="hidden" name="profile_id" value="1" />
> <select name="reason">
> <option value="None">None</option>
> <option value="Retired">Retired</option>
> </select></form>
> </div>
>
> <div id="dialog-member-1">
> <form action="http://localhost/member" method="post" id="delete-1"
> name="del" class="delete-member">
> <input type="hidden" name="profile_id" value="2" />
> <select name="reason">
> <option value="None">None</option>
> <option value="Retired">Retired</option>
> </select></form>
> </div>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "jQuery UI" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<jquery-ui%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jquery-ui?hl=en.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en.