I am using jQuery quite heavily in my project, and as with most projects I do, I have included jQuery via the Google API rather than the Yii scriptMap.
$cs=Yii::app()->clientScript; $cs->scriptMap=array( 'jquery.js'=>false, 'jquery.ajaxqueue.js'=>false, 'jquery.metadata.js'=>false, ); echo CGoogleApi::init(); echo CHtml::script( CGoogleApi::load('jquery','1.4.2') . "\n". CGoogleApi::load('jqueryui','1.8.0') . "\n" );
This reduces load time for our users since they often have this jQuery file already cached from other sites, plus it reduces bandwidth load on our server. I have used it without issue for months, even transitioning from jQuery 1.3.2 to 1.4.2 before Yii 1.1.1 was released.
Now however, I have just been trying to implement CGridView in one of my admin views, and I am getting errors which I am struggling with.
jQuery is not defined http://www.....com/assets/8c95b397/jquery.ba-bbq.js Line 814
jQuery is not defined http://www.....com/assets/28d1d516/gridview/jquery.yiigridview.js Line 169
jQuery("#yw0").yiiGridView is not a function http://www.....com/<controller>/<action> Line 144
At first I thought it might be an issue with Yii 1.1.0 and jQuery 1.4.2, but I have since upgraded to 1.1.1 and the problem remains.
If I remove the first codeblock I pasted here, the problem goes away, but I really don't WANT to use jquery from Yii - I want to use the Google API version for the reasons I specified above. It seems as if the problem MIGHT be caused by the absence of jquery.yii.js, but is there a way to have this included from my application without inclusing the jQuery library as well?