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.

jQuery replaceWith command

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

Related topics

1 call to ajax_command_replace()
file_ajax_upload in modules/file/file.module
Menu callback; Shared Ajax callback for file uploads and deletions.

File

includes/ajax.inc, line 902

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.