Answer the question
In order to leave comments, you need to log in
How can select 2 kartik be reinitialized?
I have an ajax layout validation that comes in as a response and is replaced with html. Accordingly, select2 demos.krajee.com/widget-details/select2 is not initialized. How can I re-initialize it, because I have such garbage happening
The select2 settings themselves
<?= Select2::widget([
'name' => 'LoginForm[type]',
'hideSearch' => true,
'data' => ['username' => 'Логин', 'phone' => 'Телефон'],
'options' => ['id' => 'auth_type', 'class' => 'input select_type_auth']
]) ?>
Answer the question
In order to leave comments, you need to log in
The question is not on the Yii2 topic, this refers to JS and Select2 itself, dig in this direction. And I offer such JS. Try it, it might work...
/*<!--Устраняем баг Select2-->*/
$(document).ready(function () {
$.fn.modal.Constructor.prototype.enforceFocus = function () {
};
});
/*<!--/Устраняем баг Select2-->*/
$(".select2me-filter").select2("destroy");
... Here do option updates you need
$(".select2me-filter").select2();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question