I'm calling an Ajax function in a field collection. But after hitting 'Add another item' button, form looses Ajax effect. I want to bind the Ajax with form event after clicking on 'Add another item' button. Can anyone help?

  • I am also having this problem. I was able to do this with the beta4 release but something has changed with beta5.
    – user12670
    Commented Jan 13, 2013 at 18:00
  • Actually we solved this problem with form_alter Commented Jan 16, 2013 at 9:28

2 Answers 2


Sounds like you need to use Drupal.behaviors and not just document.ready for your javascript.

Drupal uses a "behaviors" system to provide a single mechanism for attaching JavaScript functionality to elements on a page. The benefit of having a single place for the behaviors is that they can be applied consistently when the page is first loaded and then when new content is added during AHAH/AJAX requests.

More info on Drupal.behaviors here

  • thanks for reply...actually while writing my js and ajax i have already used Drupal.behaviors but still its loosing the effect of ajax on page load Commented Jan 2, 2013 at 11:20

Actually on reload of page Ajax looses its effect. So we solved this problem through form alter.

$form['#after_build'] gives us all the detail after save so that helps to retrieve values again and filter.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.