I made it to open a custom multi-page form in a jquery ui dialog, but can't figure out how to close it.

1)

Menu hook get's me to a page callback, which is the parent.
I have added the parent_js() here and a button, which i can catch by an event with jquery:

function custom_test_page(){
    jquery_ui_dialog_parent_js();
....
   <form><input id="button" type="button" value="'Open Modal Dialog"></form>

2)
my jquery script looks like this:

    $(function() {
        $("#button").click(function(event){

            event.preventDefault();
            var aurl = '/custom_form';
            Drupal.jqui_dialog.open({url:aurl, width:640});
         });
    });

3)

Then my form, which is the child, look like this:

function custom_form(&$form_state = NULL) {
    jquery_ui_dialog_child_js();
    ....
           // my drupal form
    ...

4)
Form submit contains a redirect:

function custom_form_submit($form, &$form_state) {
....
  // store form data
.....
    $form_state['redirect'] = 'node/'. $node->nid;

}

After form sumbit, i would like to close the dialog, but the parent should follow the redirect.

I was not able to find a drupal api function in the module, which closes it, just a javascript dialog close.

I have used modalframe prior to jquery_ui_dialog, which had the modalframe_close_dialog() method,
but modalframe looked quite overloaded to me and it wasn't easy to theme - so i would like to switch to jquery ui dialog.

Do i have to close it using javascript? How can this be done?

Thanks for help.

Comments

pero’s picture

Status: Active » Closed (fixed)

i found out that close methods were removed from code - i will go back to modalframe api. sry.

EugenMayer’s picture

Status: Closed (fixed) » Active

Well thats exactly why modalframe is overloaded, it covers and API behind an api. Nevertheless, you can close your dialog as you are used too

Open..

Drupal.jqui_dialog.open(..);

Close

Drupal.jqui_dialog.close();

and that method does nothing more then:

$('#jq-ui-dialog-iframe').dialog('close'); 
EugenMayer’s picture

Status: Active » Fixed
EugenMayer’s picture

Status: Fixed » Closed (fixed)
broncomania’s picture

I ran into the same problem. I have a node form and i want that this get closed after successfully validation and submitting. Can you give me a little bit more infos how the infos from the dialog can close the dialog itself.

Is this done with adding the following code in the result page

drupal_add_js('Drupal.jqui_dialog.close();','inline');

because in my case it didn't work maybe I have an understanding problem. Maybe you had the same problems during the development and you know how it works. I can't believe that i am the only one with this question... is the solution so simple and i can't see it?

thx
Frank

mac2000’s picture

Priority: Normal » Minor

Have same troubles

Drupal.jqui_dialog.close() - from parent - do nothing
solution is:

if(typeof Drupal.jqui_dialog.container !== 'undefined') {
Drupal.jqui_dialog.container.dialog('close');
}