G
G
good_beginer2018-12-24 12:58:04
Yii
good_beginer, 2018-12-24 12:58:04

Why is yii2 not reading jquery file?

public $js = [
        'js/jquery3-3-1.min.js',
        'js/style.js',
    ];

Here's the thing.. style.js works but jquery only works when connected directly via script, what could be the reason?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kim, 2018-12-25
@good_beginer

If your AppAsset depends on YiiAsset, then keep in mind that YiiAsset already depends on the framework's built-in JqueryAsset. This way you include two jquery.
You can explicitly specify in the configuration that your jquery should be used instead of JqueryAsset :

'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'sourcePath' => '@frontend/assets',
                    'js' => [
                        'js/my-jquery.js',
                    ],
                ],
            ],
        ],

M
Maxim Timofeev, 2018-12-24
@webinar

yii doesn't have to read anything, it includes files. So you need to check whether you have connected it and if not, check whether it is there from where you connect it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question