I am trying to clone a row which contains select2 tool ,when i clone that row using jQuery the cloned select2 is not responding.In image given below first select2 which is o
I've actually created account to answer this, since it took me a while to make it work.
This is not working when used before cloning:
$('.selectpicker').select2('destroy')
But this works in my case:
$('.selectpicker').select2('destroy');
$('.selectpicker')
.removeAttr('data-live-search')
.removeAttr('data-select2-id')
.removeAttr('aria-hidden')
.removeAttr('tabindex');
Just remove all the additional attributes which select2 adds.
Edit #1
Ok so seems like You also got to remove ID from the element that is being cloned since select2 tries to add it's own unique id when none is found on the select, but when You do have select it's getting messy and selet2 attaches only on the last element with the same ID.