AtanuCSE AtanuCSE - 7 months ago 13
Javascript Question

Dynamically loaded items not shown in second time on dropdown (Harvesthq Chosen)

I'm using this following tool to make the dropdown searchable and look nice.

Harvesthq Chosen

First I'm loading the data dynamically in dropdown and applying this code to apply the effect.

$(".chosen-select").chosen();


It works just fine. Everything ok. Then depending on some option I want to empty all data and insert new options. Now problems occur. The newly added options are not shown. Old options are still visible.

So I checked with the firebug.
Select
tag contains my desired data, but it's showing wrong data(Old ones).Some kind of
div
is visible. I tried to apply the
chosen
methd once again. But not working. Then I tried

$("#form_field").trigger("chosen:updated");


And not working either. Can anybody tell me what is missing?

I want to clear and load data dynamically multiple times in dropdown and apply the chosen effect.

Answer

This worked for me

$("#form_field").trigger("liszt:updated");