R
R
Ruslan Absalyamov2019-06-10 11:19:46
Yii
Ruslan Absalyamov, 2019-06-10 11:19:46

Why doesn't js code work inside my modal window?

The modal is rendered with renderAjax and replaces the . As a result, it turns out that some components that were connected using js are not initialized and cannot, I don’t understand why. Here is the code

<?php
namespace frontend2\views;

use yii\web\AssetBundle;

class LKAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [

    ];
    public $js = [
        '/lk/static/js/script.js?v=1.1.2',
        '/lk/static/js/vendor.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset',
    ];

    public $jsOptions = ['position' => \yii\web\View::POS_HEAD];
}

In the template I connected it LKAsset::register($this);
And when I already call in the modal window
<?= Html::input('money', 'RegistryArkBanks[contract_sum]', Html::encode($model->contract_sum), [
                'class' => 'input _fill'
            ]) ?>

<?= Html::input('datepicker', 'RegistryArkBanks[date_start_overdue]', !empty($model->date_start_overdue) ? date('Y-m-d', $model->date_start_overdue) : null, [
                'class' => 'input _fill'
            ]) ?>

It doesn’t work to initialize it, writes Uncaught TypeError: $(...).datepicker is not a function
Although without this modal, everything is initialized normally

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question