function ajax_command_replace

Creates a Drupal Ajax 'insert/replaceWith' command.

The 'insert/replaceWith' command instructs the client to use jQuery's replaceWith() method to replace each element matched matched by the given selector with the given HTML.

This command is implemented by Drupal.ajax.prototype.commands.insert() 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.

$html: The data to use with the jQuery replaceWith() method.

$settings: An optional array of settings that will be used for this command only.

Return value

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

See jQuery replaceWith command

Related topics

4 calls to ajax_command_replace()
system_date_time_lookup in drupal/core/modules/system/system.admin.inc
Ajax callback; Returns the date for a given format string.
ViewEditFormController::rebuildCurrentTab in drupal/core/modules/views/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
Regenerate the current tab for AJAX updates.
views_ajax in drupal/core/modules/views/includes/ajax.inc
Menu callback to load a view via AJAX.
views_ui_ajax_callback in drupal/core/modules/views/views_ui/views_ui.module
Page callback: Calls a method on a view and reloads the listing page.

File

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

Code

function ajax_command_replace($selector, $html, $settings = NULL) {
  return array(
    'command' => 'insert',
    'method' => 'replaceWith',
    'selector' => $selector,
    'data' => $html,
    'settings' => $settings,
  );
}