1 ajax.inc ajax_command_open_dialog($selector, $title, $html, array $dialog_options = array())

Provides an AJAX command to open content in a dialog.

This command is implemented by Backdrop.ajax.prototype.commands.openDialog() defined in misc/dialog.ajax.js.

Parameters

string $selector: The selector of the dialog.

string $title: The title of the dialog.

string $html: HTML that will be placed in the dialog.

array $dialog_options: (optional) Options to be passed to the dialog implementation. Any jQuery UI option can be used. See http://api.jqueryui.com/dialog.

Return value

array An array suitable for use with the ajax_render() function.

Related topics

File

core/includes/ajax.inc, line 1347
Functions for use with Backdrop's Ajax framework.

Code

function ajax_command_open_dialog($selector, $title, $html, array $dialog_options = array()) {
  // Add the library for handling the dialog in the response.
  backdrop_add_library('system', 'backdrop.dialog.ajax');

  // jQuery UI does not allow markup in its titles, and does its own escaping.
  // The value passed in should already be escaped (as it would be from
  // backdrop_get_title()), so we decode it back to the original characters.
  $title = html_entity_decode(strip_tags($title), ENT_QUOTES);

  $dialog_options['title'] = $title;

  // For consistency ensure the modal option is set to TRUE or FALSE.
  $dialog_options['modal'] = isset($dialog_options['modal']) && $dialog_options['modal'];

  return array(
    'command' => 'openDialog',
    'selector' => $selector,
    'data' => $html,
    'dialogOptions' => $dialog_options,
  );
}