Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Chosen currently activates on page load, and replaces normal select boxes with Chosen select boxes.
However, I have a custom form with an 'add more' button. When you click on the 'add more' button, it adds another fieldset via AJAX. The problem is, on these AJAX-appened form elements, you won't have Chosen formatting, because Chosen only does the replacement on page load.
Is there a way to trigger Chosen to also replace the select boxes on the AJAX-appended content?
Comments
Comment #1
Dave ReidChosen uses Drupal.behaviors and attach which means it should work out of the box with anything loaded via Drupal core's native AJAX API. Is it not actually working? Which version of the Chosen module and library are you using?
Comment #2
micromegas CreditAttribution: micromegas commentedBack in October, I had to use
in order to get Chosen to work after an AJAX call.
Now, going back and re-testing using the latest versions of the Chosen module and library, it is working correctly.