Util to render dialog in ajax callback.
bool $is_modal: (optional) TRUE if modal, FALSE if plain dialog. Defaults to FALSE.
function _ajax_test_dialog($is_modal = FALSE) {
$content = ajax_test_dialog_contents();
$response = new AjaxResponse();
$title = t('AJAX Dialog contents');
$html = drupal_render($content);
if ($is_modal) {
$response
->addCommand(new OpenModalDialogCommand($title, $html));
}
else {
$selector = '#ajax-test-dialog-wrapper-1';
$response
->addCommand(new OpenDialogCommand($selector, $title, $html));
}
return $response;
}