jQuery UI and CJui Widgets

Basically I manually include jQuery and jQuery UI scripts in my layout file and I prevent Yii from publishing it’s own jQuery library. As follows:


<?php echo CHtml::scriptFile(bu('js/jquery-1.4.2.min.js')); ?>


<?php echo CHtml::scriptFile(bu('js/jquery-ui-1.7.2.custom.min.js')); ?>


<?php

Yii::app()->clientScript->scriptMap=array(

	'jquery.js'=>false,

);

?>

The problem I’m experiencing now is that if I use any of the CJui Widgets they will also publish their own version of jQuery UI. I tried doing ‘jquery-ui.js’=>false, in my scriptMap but that does not have any effect.

I’m using v1.1.3

You should set scriptFile and cssFile to false.

You can achive this in config/main using widgetFactory.

something like that:




	  'widgetFactory'=>array(

			'class'=>'CWidgetFactory',

			'widgets'=>array(

				'CJuiDatePicker'=>array('cssFile'=>false, 'scriptFile'=>false)

			)

		),	




Now I am getting an error message:

jQuery("#mydialog").dialog is not a function

That’s good, it proves that CWidgetFactory did his job, by preventing to include the Yii version of jquerui.

Now you have to include your own version.

Yes it’s already included at the top!

That is strange, maybe your version does not include dialog.

This error simply states that you miss the code of dialog, that is defined by js/jquery-ui-1.7.2.custom.min.js.

This is not a problem with framework, just check if the files really exist in your page and if they are corrected.

Yes boss, you were right. I had a very minimal version of jQuery UI that did not include dialog or tabs and many of the other widgets! I have now downloaded and included the latest version (1.8.5) and all works well now! Only slight drawback is the size of the new script - 199KB! Ouch!