L
L
lolka022021-09-03 08:55:12
Yii
lolka02, 2021-09-03 08:55:12

How to include in yii2 view js file from a module located in common/modules...?

How to connect in yii2 view js a file from a module located in common/modules/moduleName/web/js/script.js

the module has a ModuleAsset in common/modules/moduleName/assets

class ModuleAsset extends AssetBundle
{
    public $sourcePath = '@common/modules/moduleName/web';
...
}


if this script.js was in frontend or backend you could include
$this->registerJsFile('js/script.js', ['depends' => \common\modules\moduleName\assets\ModuleAsset::className( )]);

but what about those files that are in the module?

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