[SOLVED] Javascript error with zii.widgets.CListView

Yii 1.1.7, PHP 5.2, Firefox 4 + Firebug.

I have this code:


$this->widget('zii.widgets.CListView',

                  	array(

       					'dataProvider'=>$dataProvider,

       					'itemView'=>'_detail',

       					'emptyText'=>Yii::t('App', 'No details were found.'),

       					'separator'=>'<br />',

       					'enablePagination'=>false,

       					'enableSorting'=>false,

       					'summaryText'=>''

   					));

The view renders fine, but I get this javascript error:




jQuery("#yw0").yiiListView is not a function

jQuery('#yw0').yiiListView({'ajaxUpdat...ew-loading','sorterClass':'sorter'});



The ofending code is:


jQuery('#yw0').yiiListView({'ajaxUpdate':['yw0'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'list-view-loading','sorterClass':'sorter'});

I don’t know if I’m missing something or if this is a bug.

Is there any more information you can provide? I just tested your code using 1.1.7 and FF 4 and am able to render a listing using a CActiveDataProvider of model objects w/o any js errors.

Maybe viewing your page source would provide a hint or two?

Thanks for your reply.

That’s the page, the rest is just HTML markup in the layout. The head has this:


<script type="text/javascript" src="/assets/92e1b1f7/jquery.js"></script>

<script type="text/javascript" src="/assets/92e1b1f7/jquery.ba-bbq.js"></script>

<script type="text/javascript" src="/assets/30562103/js/jquery-ui-1.8.12.custom.min.js"></script>

<script type="text/javascript" src="/assets/70d94c43/jquery.flash.js"></script>

Those are the core libs in /92e1b1f7, the jui and a Flash jq plugin.

It looks like the jquery.yiigridview.js file is not being found.

Unless you have changed the framework files (it should be in framework/zii/widgets/assets/gridview), or set the baseScriptUrl to something else (not in the options you have shown us), then the only reason I can think of is if for some reason it has been deleted from where it was published in the assets folder, and the Yii publisher hasn’t noticed it.

Try deleting everything in your assets folder then load the page again.

Woops:


$ ls framework/zii/widgets/assets/gridview

ls: no se puede acceder a framework/zii/widgets/assets/gridview: No existe el fichero o el directorio

Not found… weird, I’m redownloading the framework…

Solved. I don’t know why the files weren’t in zii.widgets.assets (but I’m sure it was a local problem, not a distribution problem). Restored from the tarball, deleted the published assets, republished and problem solved.

Thank you for your help.

You’re welcome!

I had this issue too and my jQ*.js files vanished from the \framework folder - I have avast installed and I’m wondering if it’s Script Scanner component did it.

Copying the entire "framework" folder from the latest release on the Yii site fixed all these issues.

Ahhh well, all’s well that ends well.

Peter