R
R
Ruslan Absalyamov2019-03-13 20:19:23
Yii
Ruslan Absalyamov, 2019-03-13 20:19:23

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
5c893bb7f0da1255603764.png5c893b95f2d5c342669599.png
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

1 answer(s)
M
Maxim, 2019-03-14
@rusline18

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 question

Ask a Question

731 491 924 answers to any question