A
A
Alexander2015-09-17 20:02:33
Yii
Alexander, 2015-09-17 20:02:33

How to connect a js file in yii2 (AppAssets) in an elementary way?

public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
    ];
    public $js = [
        'js/main.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',
    ];

The trick is if instead of js/main.js you specify css/main.js and transfer the js file to the css folder, then he sees all the rules.
display on the site :
What could be wrong ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2015-09-17
@matperez

Check the permissions on the js folder. Also try requesting this file directly, without including it in Asset. He is at the root. If it doesn't work, look at the web server log, it usually says why the file could not be sent.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question