yiiListView is not a functio

If I attempt to register the jquery.min.js script on a controller/view generated by using yii’s shell crud command, I get the error :

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

Here is how I am registering it.



$cs->registerCssFile(‘http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel=“stylesheet” type="text/css’);




Any help would be appre

Welcome to the forums!

Some notes:

  1. You seem to use CListView on your site. The javascript for it is not contained in jquery.min.js and you seem to have disabled the publishing/registration for it somehow. Do you use scriptMap?

  2. Do never use a hardcoded filename that points to the asset folder, to register a script! This folder has one purpose only: It’s for the framework to put published files there. You should use the assetmanager component to publish your custom files from some protected directory. See here for an example. All you ever want to do, is possibly clean that folder on upgrades.

  3. Don’t fall into the trap “i use clientscript to register all my css/js”! The clientscript register* operations are rather expensive. So there’s no need to use registerCssFile if you have a static URL. It’s better to include css with a link tag in the head section of your layout file (views/layouts/main.php).


Thanks for your reply. I implemented scriptMap, removed the hard-coded reference to the asset folder, and put the css include in a link tag.

None of these actions fixed the js error.

I believe you are right in that I have somehow disabled the publishing/registration of the js necessary for CListView.

Here is what I currently have for registering the jquery necessary to implement an accordion left nav.






Any other idea?


Check out, which js files get loaded in your browser (e.g. using firebug’s network tab). It requires the file jquery.yiigridview.js. If it’s missing, try to disalbe scriptMap completely. If it’s still missing you must be doing something strange in your code. Maybe comment out all methods that use clientScript or assetManager to track it down.

I got the same error "jQuery("#yw0").yiiListView", visible on a page with a CListView object. I did not register any extra scripts, but noticed the error appeared after creating my own theme. When I looked at the source code, I saw the listview js was called before the jquery js file which was already in the template.

The line "<?php echo CHtml::encode($this->pageTitle); ?>" also outputs the registered scripts. When you already included jquery yourself, it will not include it again (*edit: it is still included but no JQuery object is created or something, anyways: ). Make sure to put the echo line as the last element in <head> to avoid errors like this.