How to enable JQueryUI everywhere?

Hi guys,

is there a way to enable JQuery UI library everywhere in a Yii application? I’d like a way to enable all my javascript in the main.php config file with all my css. I’m trying to use scriptMap but when I use a Yii widget that uses JqueryUI too it seems that Yii include the same JS library another time and this generates error…

someone can help me please?

Thanx!

Yii::app()->clientScript->registerCoreScript(‘jquery.ui’);

You have to use this code in layout file(or eventually in your view file, depending on situation).

Thanks Ivica, but if I want to set this in the config main.php file is possible or not? As I’ve have just done for jquery.js and jquery.min.js using the scriptmap array of clientscript component:

scriptmap => array(

‘jquery.js’ => true,

‘jquery.min.js’ => false,

)

I think you should be able to do something like this in config file:


'clientScript'=>array(

'scriptMap'=>array(

'ui.js'=>'jquery/ui/1.8.14/jquery-ui.min.js',

),

),

And then you will reference to it as ui.js for example.

I have added this script in config/main.php component. But it don’t works




'clientScript'=>array(

            'scriptMap'=>array(

                'jquery.js' => true,

                'jquery.min.js' => false,

            ),

        ),

Not sure it’s a good idea but I added this in the base controller.




class Controller extends CController

{

    ...


        public function beforeAction($action)

	{

		Yii::app()->clientScript->registerCoreScript('jquery.ui');

		Yii::app()->clientScript->registerCssFile(

                    Yii::app()->clientScript->getCoreScriptUrl().

                    '/jui/css/base/jquery-ui.css'

                );

		

		return parent::beforeAction($action);

	}

}

Works but perhaps not conventional.