Pb with Chosen plugin

Pb with Chosen plugin

Hi all,

I'd like to change options of a list dynamicaly with Ajax.
Here's my code (simplified for more convenience) :

//Ajax request here ....

  1. $('#my_select').empty();
  2. $('#my_select').append(new_options_in_html);

So far so good, the previous options are deleted and the new ones are inserted
in the #my_select list (I've checked with Firebug).
The problem is that the new options won't display in the list.

Seemingly the Chosen plugin generates this code for the display:

  1. <div id="my_select_chzn" class="chzn-container chzn-container-single chzn-container-single-nosearch" style="width: 27px;" title="">
  2. <a class="chzn-single chzn-default" tabindex="-1">
  3. <span>Select an option</span>
  4. <div>
  5. <b></b>
  6. </div>
  7. </a>
  8. <div class="chzn-drop">
  9. <div class="chzn-search">
  10. <input type="text" autocomplete="off" readonly="">
  11. </div>
  12. <ul class="chzn-results"></ul>
  13. </div>
  14. </div>

The "fake" options should be displayed in ul chzn-results, but
in my case nothing happens.

  1. $('#my_select').trigger('chosen:updated');
Doesn't work.

  1. $('#my_select').toggle('chosen:updated');
The list appears as rough html and disappears whenever options change.

So can someone helps me Please ?


Thanks for advance.