Yii And Jquery

Some points on how to work with jQuery in Yii -

1)Load Yii’s jquery and jQuery UI on page manually


<?php 

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

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

?>

Benifits -

1)This will check if jQUery is already included on the page and

prevent it from loading more than once.

2)Yii will automatically include compressed version if production mode is selected.

2)Prevent Yii’s scripts from loading on page

i)To prevent the jquery from loading on specific page -


<?php 

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

	$cs->scriptMap=array(

		'jquery.js'=>false,

	); 

?>

ii)To prevent Yii’s jQuery in app put this in config file -


<?php


'components' => array(

   // ...

     

   // -- start here --

     'clientScript' => array(

         'scriptMap' => array(

            'jquery.js' => false,

            'jquery.min.js' => false,

         ),

      ),

   // --  end here --

 

   // ...

),


?>

3)Upgrade Yii’s jQuery and jQuery-UI ?

1)Download the latest versions of jQuery and jQuery UI from jQuery website.

2)Save Uncompressed version as jQuery.js and jQUery-ui.js

3)Save compressed version as jQuery.min.js and jQuery-ui.min.js

4)Add these four files to framework/web/js/source folder and you are done.

Hope this will help for somwone…

Nice one :)

thanks

its solve my problem