0

I have a form with AJAX-enabled textfields. I currently have it working such that when a textfield loses focus, its AJAX callback is called.

$form['entry'][] = array(
  '#type' => 'textfield',
  '#ajax' => array(
    'callback' => '_my_module_ajax_textfield_callback',
    'wrapper' => 'entry-container',
    'method' => 'replace',
   ),
);

What I don't like is that the callback occurs even if nothing has changed. So if I am trying to tab over a bunch of inputs, they all call their AJAX. Is there a way to only call the AJAX callback if something has changed for that input?

I think there's probably a way to do it with AJAX commands, but considering that I just started learning AJAX, I have no idea. The AJAX examples I've seen don't cover this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.