Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jQuery UI to an Asset Bundle

I have the following asset bundle and i would like to add jQuery UI as part of it as well. How can I do it?

<?php
namespace app\assets;

use yii\web\AssetBundle;

class AdminAsset extends AssetBundle
{
    public $basePath = '@webroot/assets-admin';
    public $baseUrl = '@web/assets-admin';

    public $css = [
        'css/common.css',
        'css/animations.css',
        'css/editor.css',
        'css/form.css',
        'css/fileupload.css',
        'css/template.css',
        'css/icons.css',
    ];
    public $js = [
        'js/libs/modernizr.js',
        'js/script.js'
    ];
    public $depends = [
        'yii\web\JqueryAsset',
        'yii\web\YiiAsset',
    ];
} 
like image 255
Balaji Viswanath Avatar asked Jan 30 '15 14:01

Balaji Viswanath


1 Answers

At first install official JUI Extension for Yii 2.

Then add yii\jui\JuiAsset to list of dependent assets:

public $depends = [
    'yii\jui\JuiAsset',
    ...       
];

yii\web\JqueryAsset in this case is not required because JuiAsset already has it in dependencies list so it will be included as well.

like image 169
arogachev Avatar answered Sep 23 '22 02:09

arogachev