function dialog_example_ajax_callback in Dialog 7
Same name and namespace in other branches
- 6 example/dialog_example.module \dialog_example_ajax_callback()
Menu callback for our AJAX
1 string reference to 'dialog_example_ajax_callback'
- dialog_example_menu in example/
dialog_example.module - Implementation of hook_menu().
File
- example/
dialog_example.module, line 58 - Provides a demonstration of using the Dialog API.
Code
function dialog_example_ajax_callback($ajax) {
// If we're using JavaScript, display the content within the dialog.
if ($ajax) {
// Construct the dialog's content.
$content = dialog_example_page();
// Options that are passed to the jQuery UI dialog. See the jQuery UI
// website for more available options: http://jqueryui.com/demos/dialog/
$options = array(
'height' => rand(25, 75) . '%',
'width' => rand(25, 75) . '%',
'position' => 'center',
'title' => t('Dialog example'),
);
$commands = array();
$commands[] = dialog_command_display($content, $options);
ajax_deliver(array(
'#type' => 'ajax',
'#commands' => $commands,
));
}
else {
// If the user isn't using JavaScript, just show the normal page.
return dialog_example_page();
}
}