Why does CJuiWidget not using registerCoreScript

when I want to use jquery-ui source code (not the min version) i edited the ‘framework/web/js/packages.php’ file to: (only the jquery.ui section)




	'jquery.ui'=>array(

		'js'=>array(YII_DEBUG ? 'jui/js/jquery-ui.js' : 'jui/js/jquery-ui.min.js'),

		'depends'=>array('jquery'),

	),



then, because I use the CJuiAutoComplete too, I got 2 script tags for jquery-ui.js AND jquery-ui.min.js

After some digging, i’ve found out that CJuiWidget->registerCoreScripts function is not using ClientScript->registerCoreScript(‘jquery.ui’). Instead it registered the script files manually. See bellow:




protected function registerCoreScripts()

	{

		$cs=Yii::app()->getClientScript();

		if(is_string($this->cssFile))

			$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$this->cssFile);

		else if(is_array($this->cssFile))

		{

			foreach($this->cssFile as $cssFile)

				$cs->registerCssFile($this->themeUrl.'/'.$this->theme.'/'.$cssFile);

		}


		$cs->registerCoreScript('jquery');

// should use $cs->registerCoreScript() <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />?

		if(is_string($this->scriptFile))

			$this->registerScriptFile($this->scriptFile);

		else if(is_array($this->scriptFile))

		{

			foreach($this->scriptFile as $scriptFile)

				$this->registerScriptFile($scriptFile);

		}

	}



Is it a bug? Or am I doing it wrong?

You probably mean, it doesn’t use the package system. There’s a ticket for this here:

http://code.google.com/p/yii/issues/detail?id=2378

BTW you should not edit packages.php. Instead you can configure the packages property of your clientScript application component.