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 solved this by creating a different clone function:
jQuery.fn.cloneSelect2 = function (withDataAndEvents, deepWithDataAndEvents) {
var $oldSelects2 = this.is('select') ? this : this.find('select');
$oldSelects2.select2('destroy');
var $clonedEl = this.clone(withDataAndEvents, deepWithDataAndEvents);
$oldSelects2.select2();
$clonedEl.is('select') ? $clonedEl.select2() :
$clonedEl.find('select').select2();
return $clonedEl;
};