0

I have a button that triggers an AJAX callback with the form api like so :

$form['show_modal'] = array(
 '#type' => 'submit',   
 '#value' => t('Some crazy text'),
 '#ajax' => array(
     'callback' => 'myCallback',
     'wrapper' => 'myWrapper',      
 ),
 '#suffix' => '</div>',
);

I then do some stuff and return my new form and display it (working).

 return $form['myNewForm'];

I want to display it in a custom jQueryUI dialog, but when I do that my AJAX callback doesn't work anymore ...

 //On click, open modal
 $('#showModale').click(function(){$('#myWrapper').dialog("open");});
 //Modal itself
 $("#myWrapper").dialog({
  autoOpen: false,
  show: {
    effect: "blind",
    duration: 300
  },
  hide: {
    effect: "blind",
    duration: 300
  },
  height: 400,
  width: 1000,
  modal: true,
  resizable: false,
  draggable: false,
});

Any ideas about it ?

5
  • Your post is vague. You want to post $form['myNewForm'] in the modal dialog? Commented Jun 4, 2015 at 8:28
  • Where is your $form['myNewForm'] code? Commented Jun 4, 2015 at 8:29
  • My code is pretty long so I made a similar example. The form is correctly returned, but I think the modal is not working properly with with my wrapper for an unknown reason. I have a second modal who works properly (but filled via an external JS) ...
    – Germain
    Commented Jun 4, 2015 at 8:34
  • Please correct me if Im wrong, you want to display a dialog when you click the ajaxified button? Commented Jun 4, 2015 at 8:47
  • You're right, i want to display my generated form in a modal (currently it's displayed directly on the page in a wrapper) after the callback returned it.
    – Germain
    Commented Jun 4, 2015 at 8:56

1 Answer 1

0

a simpler approach might be to include the form in a custom block, and set it's css to match the modal design you want but set the initial block display to none. Then use an onclick to show the block using whatever transition you want

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.