function ajax_command_data

ajax_command_data($selector, $name, $value)

Creates a Drupal Ajax 'data' command.

The 'data' command instructs the client to attach the name=value pair of data to the selector via jQuery's data cache.

This command is implemented by Drupal.ajax.prototype.commands.data() defined in misc/ajax.js.

Parameters

$selector: A jQuery selector string. If the command is a response to a request from an #ajax form element then this value can be NULL.

$name: The name or key (in the key value pair) of the data attached to this selector.

$value: The value of the data. Not just limited to strings can be any format.

Return value

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

See also

http://docs.jquery.com/Core/data#namevalue

Related topics

File

includes/ajax.inc, line 1211
Functions for use with Drupal's Ajax framework.

Code

function ajax_command_data($selector, $name, $value) {
  return array(
    'command' => 'data',
    'selector' => $selector,
    'name' => $name,
    'value' => $value,
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!ajax.inc/function/ajax_command_data/7.x