| 7 ajax.inc | ajax_command_html($selector, $html, $settings = NULL) |
| 8 ajax.inc | ajax_command_html($selector, $html, $settings = NULL) |
Creates a Drupal Ajax 'insert/html' command.
The 'insert/html' command instructs the client to use jQuery's html() method to set the HTML content of each element matched by the given selector while leaving the outer tags intact.
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 html() 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 also
http://docs.jquery.com/Attributes/html#val
Related topics
3 calls to ajax_command_html()
File
- includes/
ajax.inc, line 874 - Functions for use with Drupal's Ajax framework.
Code
function ajax_command_html($selector, $html, $settings = NULL) {
return array(
'command' => 'insert',
'method' => 'html',
'selector' => $selector,
'data' => $html,
'settings' => $settings,
);
}
Login or register to post comments
Comments
create textfield in select option item change
create a form with select option, on change of option fire ajax and call my custom function,in my function i want create a textfield with autocomplete feature,when i comment '#path_autocomplete' in my function every thing is ok ,create a textfield with out outocomplete feature, but when uncomment '#autocomplete_path' => "user/autocomplete", it not work(it create a text feild with autocompele icon in right of it but really not work and not autocomplete:( ) and when i see the firebug console see this error
'Syntax error, unrecognized expression: #' when calling method: [nsIDOMEventListener::handleEvent] [Break On This Error]
Filtered chrome url chrome://firebug/content/net/spy.js
<?php
$element['field_terms'] = array(
'#type' => 'select',
'#title' => t('location'),
'#options' =>$terms,
'#ajax' => array(
'event' => 'change',
'callback' => 'country_select_func',
'wrapper' => 'city-term',
'method' => 'append',
'effect' => 'fade',
),
);
?>
and in country_select_func
<?php
function country_select_func($form, $form_state) {
$form['city_list_item'] =array(
'#type' => 'textfield',
'#title' => t('select city (optional)'),
'#autocomplete_path' => "user/autocomplete",
'#weight' => -1,
);
return ($form['city_list_item']);
}
?>
how i can resolve this problem?