select2 search getting removed when new select2 code example
Example: select2 destroy
if ($('#mySelect2').hasClass("select2-hidden-accessible")) {
// Select2 has been initialized
$('#mySelect2').select2('destroy');
}
if ($('#mySelect2').hasClass("select2-hidden-accessible")) {
// Select2 has been initialized
$('#mySelect2').select2('destroy');
}