Versions newer than v4.0.3 seem to have issues when destroy/cloning select2's
See original GitHub issueThe 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:
- Created 6 years ago
- Reactions:5
- Comments:8 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Also getting the same behavior with versions > 4.0.3.