4

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 Jan 13 '13 at 18:00
  • Actually we solved this problem with form_alter – sneha.kamble Jan 16 '13 at 9:28
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 – sneha.kamble Jan 2 '13 at 11:20
1

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, privacy policy and cookie policy

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