Answer the question
In order to leave comments, you need to log in
Why aren't scripts written in the assets folder?
created a widget in common/widget connected its asset in this way
public function init()
{
ModalAssets::register($this->getView());
}
class ModalAssets extends AssetBundle
{
public $publishOptions = [
'forceCopy' => YII_DEBUG,
];
//public $basePath = '@backend/widgets/companyModal';
public $sourcePath = __DIR__ . '/assets';
public $baseUrl = '@web';
public $css = [];
public $js = [
'/js/modal.js'
];
public $depends = [
YiiAsset::class,
BootstrapAsset::class,
];
}
Answer the question
In order to leave comments, you need to log in
Good morning.
Try moving it ModalAssets::register($this->getView());
to the method run();
In ModalAssets, in the init() method
public function init()
{
$this->sourcePath = __DIR__ . '/assets';
parent::init();
}
assets /* js and css */
view /* view widget */
ModalWidget.php
ModalAssets.php
public $js = [
'/js/modal.js'
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question