I'm struggling to get my form to have Ajax run javascript. I can do the replacement example ok that is located at http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax
And sometimes if I put the output open the output form that in script tags, I'll get some outcomes, but I'll also get a lot of errors.
<script>
JS in here
</script>
I'm thinking what I want to do is return commands. All I'm trying to do right now is get a google map to recenter. I'm not using the maps module because I want Maps API V3.
My code I'm trying to run right now is:
function mobile_location_form($form, $form_state){
$form['container']['controls']['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#ajax' => array(
'callback' => 'ajax_example_simplest_callback',
'wrapper' => 'replace_textfield_div',
),);
$form['container']['controls']['replace_textfield'] = array( // ajax writes our new map locations here.
'#prefix' => '
',
'#suffix' => '
',
);
return $form;
}
function ajax_example_simplest_callback($form, $form_state) {
$commands = array();
$commands[] = 'oMap.setCenter(google.maps.LatLng(0,0))';