question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Versions newer than v4.0.3 seem to have issues when destroy/cloning select2's

See original GitHub issue

The preferred approach is to .destroy('select2') and then .clone() and then .select2() again. However in versions of select2 > 4.0.3 this functionality is not working.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rohanccommented, Jun 9, 2019

I experienced this using v4.0.7 also.

In addition to calling .select2(“destroy”), it seems we need to remove the “data-select-id” attribute from both the SELECT and all its children. I guess these steps should be built into the destroy method itself.

https://jsbin.com/tayojamesi/1/edit?html,js,output

Also note that if the original select has an ID attribute, then you need to give the clone its own ID. See also #5501.

0reactions
JonathanSeguincommented, Jun 28, 2019

Also getting the same behavior with versions > 4.0.3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Untitled
#1 When placing select2 inside the jQuery dataTable, the select2 is not working, when I move it outside the table that is managed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found