D7 form field #ajax callback not called on autocomplete field I have an entity reference field, and I'd like to do some ajax so that when a value is selected for that field, some text is displayed in a div below the field. Since it's on a node edit form, I'm using a form alter hook:

/**
 * Implementation of hook_form_FORM_ID_alter()
 */
function mymodule_form_blog_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['field_video_reference']['#ajax'] = array(
    'callback' =&gt; 'mymodule_video_ajax_callback',
    'wrapper' =&gt; 'my-path-div',
  );

  $form['my_path'] = array(
    '#markup' =&gt; t('My path'),
    '#prefix' =&gt; '&lt;div id="my-path-div"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#weight' =&gt; 6,
  );

  if (!empty($form_state['node']-&gt;field_video_reference)) {
    $form['my_path']['#markup'] = 'Token path: http://www.mysite.org/node/' . $form_state['node']-&gt;field_video_reference['und'][0]['target_id'];
  }
}

function mymodule_video_ajax_callback($form, $form_state) {
  return $form['my_path'];
}


The code works fine when a the form is displayed and the field already has a value.  However, the most likely use will be when the node is first being created, so I want this to trigger when a value is first added.  The problem is, my callback is not being triggered at all.  I'm following the first example in the "Javascript in Drupal" chapter in "Drupal 7 module Development," so from what I see, I it should be called when the field value is changed.  Does this not work for fields that are already using ajax to get a value in the first place (i.e. an autocomplete field like this one), or is there something else I'm  missing?

Thanks.

UPDATE: In case it is an issue with doing this on an autocomplete field, I added another test field that is a select list and attached the ajax to it as above, but the form is still not rebuilt when I select a value.
I think the problem is that $form['field_video_reference'] is a container and you want to attach the ajax event to the actual text field element.

If you inspect the $form array you should see the correct place to put it. In needs to be at the same level as the #type =&gt; 'textfield' (or entity reference) property.

I think the path will be something like:

$form['field_video_reference'][LANGUAGE_NONE][0]['value']['#ajax'] = array(
    'callback' =&gt; 'mymodule_video_ajax_callback',
    'wrapper' =&gt; 'my-path-div',
);