Question regarding jquery and jqueryui

I was looking on how to use google cdn for serving jquery and came across this code for the main config under components:




'clientScript' => array(

	'packages' => array(

		'jquery' => array(

			'baseUrl' => '//ajax.googleapis.com/ajax/libs/jquery/1.7.1/',

			'js' => array('jquery.min.js'),

		),

	),

),



So that works fine and dandy. I then figured I would do the same with jqueryui, so I added the following




'jquery.ui' => array(

	'baseUrl' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/',

	'js' => array('jquery-ui.min.js'),

),



It works but I noticed that doing this makes jqueryui load up first before jquery, thus giving me “jquery not defined” errors. I’m including jqueryui in my view files using the following:


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

Only way I could get jquery to load up first is to register it as well before jqueryui:




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

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



Is this correct, or am I missing something?

Have you checked this?

http://www.yiiframework.com/wiki/259/serve-jquery-and-jquery-ui-from-google-s-cdn/

Hi wisp. Yup, was the first one I ran into when searching for how to serve the js files from google’s cdn. I just modified it to import jquery ui as well (I don’t use the widget factory so I skipped the widgetFactory section of the config)

JQuery isn’t loaded by default. When a widget is used, JQuery will then be loaded automatically.

Since you don’t use the widgets, JQuery will probably never be loaded.

Your solution is fine and is how it should be done.

He used registercorescript, so that should load jquery… I’m not sure what else could be wrong