I've seen a few examples, but I cannot get this to work. I setup a similar modal using ctools as the example provided in 'Chaos Tools AJAX Demo' - with the custom modal wizard. After submitting and dismissing the modal, I want to redirect the page, but it's not working. I've added $commands[] = ctools_ajax_command_redirect('my-module-path'); to the example module...
if ($output === FALSE || !empty($form_state['complete'])) {
// Dismiss the modal.
$commands[] = ajax_command_html('#ctools-sample', $animal);
$commands[] = ctools_modal_command_dismiss();
$commands[] = ctools_ajax_command_redirect('my-module-path');
But after the modal closes, the page remains. I've also tried ctools_ajax_command_reload(), but it wasn't reloading the page. Am I missing something to get this to work?
Thanks,
Tony
Comments
Comment #1
daffie commentedHi Tony,
I had the same problem. :(
The solution is that you must add the javascript file ajax-responder.js.
This file does the execution of the reload and redirect commands. And a lot more.
Add this line to your code.
You must place this line before declaring your ajax link to your modal form.
In the ctools_ajax_sample module you place the line in the function ctools_ajax_sample_page().
If this does not work for you, please let me know.
Comment #2
Tony Stratton commentedThat worked! Thank you very much.
Comment #3
Tony Stratton commented...closing issue...
Comment #4
nagiek commentedThanks this helped me too. I just figured all the necessary stuff would go into ctools_modal_add_js.
Comment #5
romaingar commentedthanks,
This is very useful even for ctools_modal_command_dismiss();
ctools_add_js('ajax-responder','ajax-responder');
Comment #6
parijat.chauhan commentedI face similar problem and not able to find why reload is not working