Skip to main content
improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form, and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?

  // This works (creates backend xhr call).      
  $form['title']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    #'method'// 'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['und'][0]['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?

  // This works (creates backend xhr call).      
  $form['title']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    #'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['und'][0]['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I alter the node edit form, and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus). Is there anything special that needs to be done to get #ajax to work on the body field?

  // This works (creates backend xhr call).      
  $form['title']['#ajax'] = array(
    'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
  );
  
  // Doesn't work.
  $form['body']['#ajax'] = array(
    'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    // 'method' => 'replace',
    'event' => 'focus',
  );
  
  // Doesn't work.
  $form['body']['und'][0]['#ajax'] = array(
    'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
  );
added 718 characters in body
Source Link

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?

  // This works (creates backend xhr call).      
  $form['title']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    #'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['und'][0]['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?

  // This works (creates backend xhr call).      
  $form['title']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    #'method' => 'replace',
    'event' => 'focus',
    );
  
  // Doesn't work.
  $form['body']['und'][0]['#ajax'] = array(
        'wrapper' => 'autopreview',
    'callback' => 'autopreview_ajax_callback',
    'method' => 'replace',
    'event' => 'focus',
    );
Source Link

Does #AJAX work on the body field?

Does the #AJAX FAPI property work on the body field? I've got it to work with things like submit buttons and textfields such as the title. When I form alter the node edit form and attach an #ajax array to the body field though, nothing happens. I've tried multiple event types (keyup, keypress, focus, etc). Is there anything special that needs to be done to get #ajax to work on the body field?