How to reload jquery dropkick object

NovumCoder picture NovumCoder · Jan 3, 2012 · Viewed 14.4k times · Source

Im using a simple select list and the jquery.dropkick library to make it beautiful. Now i want to change that dropkick content after the corresponding select element has been changed (a new option came in). But just calling $('#select').dropkick(); doesnt work.

And it looks like it is not supported. It would be enough just to rebuild that dropkick from scratch. Is there any possibility to "destroy" that dropkick object then rebuilding it by calling the .dropkick() method?

Answer

Diode picture Diode · Jan 3, 2012

I have faced the same issue and couldn't find a solution, but finally succeeded in getting this hack work.

$select = $("#select1");
$select.removeData("dropkick");
$("#dk_container_select1").remove();

$select.append("<option>opt4</option>");
$select.append("<option>opt5</option>");

$select.dropkick();