Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Drupal 7 JS code through the AJAX
- $form['myitem'] = array(
- '#type'=>'textfield',
- '#ajax' => array(
- 'callback' => 'my_callback',
- 'wrapper' => 'new-id',
- 'method' => 'html',
- 'effect' => 'fade',
- ),
- );
- $form['myitem2'] = array(
- '#type'=>'markup',
- '#value'=>"<div id='new-id'> I'm #new-id </div>"
- );
- function my_callback(&$form, &$form_state){
- $commands = array();
- $commands[] = ajax_command_invoke('#new-id', 'html', array('<div id="new-id2">#new.id2 here!</div>'));
- $commands[] = ajax_command_invoke('#new-id2', 'addClass', array('error'));
- return array('#type' => 'ajax', '#commands' => $commands);
- }
Add Comment
Please, Sign In to add comment