I have some select2 inputs $(".select2")
on page for results filtering. After AJAX (get) call I need to insert form $("updateForm")
received from response to bootstrap modal $("#updateProductModal")
. Everything works fine except select2 dropdowns which are not aligned with input
element. After some research I’ve founded out that is a common issue and to fix that I need add dropdownParent
to .select2()
init.
I’ve added some code on success response:
success: function (response) {
if ($method == "POST") {
location.reload();
} else {
var $form = $(response.content);
$("#updateProductModal .modal-body").html($form);
// attaching select2 to modal
$("#updateProductModal .select2").select2(
placeholder: "Your input here", // for testing purpose
);
};
},
However no placeholders are placed. I suspect that previously initialized config for $(".select2").select2(someConfig)
will ignore another select2()
call.
Is there any solution for configure new bunch of inputs contained in form with additional parameters?