0

Не могу понять как инициализировать кнопку закрытия модального окна после перезагрузки grid. Сама кнопка которая выводит скрытое содержимое работает. А вот скрыть по нажатию кнопки, не получается. Как я понял все дело в data-dismiss, как заставить его работать не могу понять. Спасибо.

Кусок когда из Gridview:

                            'country' => [
                            'label' => 'country',
                            'format' => 'raw',
                            'hAlign' => 'center',
                            'vAlign' => 'middle',
                            'value' => function ($model) {
                                $html = "";
                                $val = explode(",", $model->country);
                                if (isset($val[0]) and count($val) > 1) {
                                    return \kartik\popover\PopoverX::widget([
                                        'header' => 'Country',
                                        'placement' => \kartik\popover\PopoverX::ALIGN_LEFT_TOP,
                                        'content' => $model->country,
                                        'options' => ['data-pjax' => true ],
                                        'toggleButton' => ['label'=>$val[0], 'class'=>'btn btn-default text-info '],
                                    ]);
                                } else {
                                    return Html::encode($model->country);
                                }
                            }
                        ],

А здесь мы инициализируем заного PopoverX после pjax обновления.

    function popover_int() {
    $('[data-toggle="popover-x"]').popoverX('validateOpenPopovers');
    $('[data-toggle="popover-x"]').popoverX('destroy');
    $('[data-toggle="popover-x"]').popoverX('init');

    $('[data-toggle="popover-x"]').popoverButton('destroy');
    $('[data-toggle="popover-x"]').popoverButton('init');
}
0

1 ответ 1

0

Решил таким образом, прописал в файле главного шаблона.

$(document).on('ready pjax:beforeSend', function () {
    popoverX_destroy();
});

$(document).on('ready pjax:success', function () {
    popoverX_init();
});
$(document).on('ready pjax:timeout', function () {
    e.preventDefault()
});

function popoverX_init() {
    $('[data-toggle="popover-x"]').popoverX([]);
    $('[data-toggle="popover-x"]').popoverButton([]);
}

function popoverX_destroy() {
    $('[data-toggle="popover-x"]').popoverX('validateOpenPopovers');
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.