How to add jQuery UI to Asset Bundle

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

<?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',
    ];
} 
+4
source share
2 answers

First install the official JUI extension for Yii 2 .

Then add yii\jui\JuiAssetto the list of dependent assets:

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

yii\web\JqueryAssetin this case it is not required because it JuiAssetalready has it in the list of dependencies, therefore it will also be included.

+15
source

Since the accepted answer no longer works in Yii 2.10, I will add my solution.

CoreAsset, jui. CoreAsset, , draggable, do:

public $depends = [
    //'yii\jui\CoreAsset', // included as dependency of draggable
    'yii\jui\DraggableAsset',
];
0

All Articles