yii\bootstrap\BootstrapAsset
is not loading bootstrap.js
, and such elements as "modal" and others are not working.
class AppAsset extends AssetBundle {
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
/* theme */
'css/site.css',
/* jasny bootstrap */
'public/jasny/css/jasny-bootstrap.min.css',
/* font awesome */
'public/font-awesome-430/css/font-awesome.min.css',
/* font roboto */
'public/fonts/roboto/roboto.css',
/* Data Tables */
'public/datatables/extensions/integration/bootstrap/3/dataTables.bootstrap.css',
];
public $js = [
/* jasny bootstrap */
'public/jasny/js/jasny-bootstrap.min.js',
/* Data Tables */
'public/datatables/datajs.js',
'public/datatables/media/js/jquery.dataTables.min.js',
'public/datatables/extensions/integration/bootstrap/3/dataTables.bootstrap.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
}
Here is screen of libraries, bootstrap.js
is missing there.
If you look at the content of BootstrapAsset
bundle, you will see that there is no bootstrap.js
:
class BootstrapAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $css = [
'css/bootstrap.css',
];
}
For bootstrap.js
another asset bundle exists and it's called BootstrapPluginAsset
:
class BootstrapPluginAsset extends AssetBundle
{
public $sourcePath = '@bower/bootstrap/dist';
public $js = [
'js/bootstrap.js',
];
public $depends = [
'yii\web\JqueryAsset',
'yii\bootstrap\BootstrapAsset',
];
}
The full class name with namespace is: yii\bootstrap\BootstrapPluginAsset
.
It's included automatically when you use js dependent bootstrap widgets such as yii\bootstrap\Modal
, etc.