Yii Framework Forum: Yii And Jquery - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii And Jquery How to handle jQuery in Yii Rate Topic: ****- 1 Votes

#1 User is offline   Mangesh Lad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 19-August 11

Posted 30 January 2013 - 09:50 AM

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..
2

#2 User is offline   Blue Spy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 08-October 11

Posted 30 January 2013 - 10:28 AM

Nice one :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users