CGridView inside CJuiTabs loaded via ajax+renderPartial: error when serving from CDN

Hi there,

I am using a CJuiTabs to implement a settings page on one of my projects and I have set it to load the tab content via ajax.

Something along the following lines:

  • In the page view I render the CJuiTabs



$this->widget('CJuiTabs',array(

	'id'=>'back-office-tabs',

	'tabs'=>array(

		'Settings'=>array(

			'id'=>'settings',

			'ajax'=>$this->createUrl('site/settings'),

		),

	),

	'options'=>array(

		'cache'=>true,

	),

));



  • In the ‘site/settings’ action I render a view partially



$this->renderPartial('_settings',array(),false,true);



  • In the view I render a CGridView widget



$this->widget('CGridView',array(

	'id'=>'settings-grid',

	'dataProvider'=>new CActiveDataProvider('Settings',array(

		'sort'=>array('defaultOrder'=>'name'),

	)),

	'columns'=>array(

		'name::Name',

		'value::Value',

	),

));



It works perfectly. However, now that I want to deploy the app, I used a custom AssetManager to retrieve assets from a CDN (Amazon’s CloudFront). Basically, it prepends the CDN url to the asset url published by CAssetManager and independently I copied the contents of the public/assets folder to the CDN.

I have compared the HTML code generated by the app using both CAssetManager and my custom AssetManager and, as expected, they are exactly the same, except for the references to the CSS/JS and other resource files that are hosted in the CDN.

Therefore:

1- the asset links are rewritten properly and are refering to the proper asset files in the CDN;

2- the CDN contents match exactly the structure and contents of the public/assets folder;

Now the funny thing: I am getting a JavaScript error when executing the app using the custom AssetManager

“Uncaught TypeError: Object [object Object] has no method ‘yiiGridView’”

Both apps are running under HTTPS.

Except for this particular page, the rest of the app works great using the custom AssetManager.

Does anyone has any clue about what might be going wrong here?

Thanks!

As you have noticed, it seems that jquery.yiigridview.js is not loaded when served from CDN.

CGridView requires jquery.yiigridview.js to be loaded.

Just for double checking, you should make sure that your CDN assets contains jquery.yiigridview.js in an appropriate location.

And, I think you should make it certain that the page in question really works fine with the default asset manager after you have cleared the contents of the assets folder in the server.

If none of the above is the case, then I guess the problem should be something with the output processing of renderPartial.

I think the dumping of the ajax response that renders the grid could show some hints.