Search code examples
jqueryjquery-select2

Select2 Initialize select after appending data to existing select


In my select2 select, i need to append li after document is ready, and after appending, how can i reinitialize select2. If I once close and again open the select, the appended data are selectable but not as soon as i append. How can i reinitialize it.


Solution

  • You have to destroy the select2 on these elements and then reinitialize it.

    $("select").select2("destroy").select2();