CListView by default registers a) the core JQuery library, the BBQ JQuery plugin, c) the yiilistview JQuery plugin and d) the Ajax hooks for the pager buttons. It does this even if the ajaxUpdate parameter is set to false.
In my opinion, if the ajaxUpdate parameter is set to false then there is no reason to include any of the Javascript files. Unless (obviously) there is a need for Javascript with CListView even when not updating via Ajax, but I can’t see the need.
For the record, here’s again the code for a basic list view that does not register any CSS/Javascript:
<?php
Yii::import('zii.widgets.CListView');
/**
* SimpleListView
*
* Custom CListView widget that does not publish any assets. They are only
* required for AJAX enabled list views.
*/
class SimpleListView extends CListView
{
/**
* Override CListView::baseScriptUrl to prevent asset publishing in init()
*
* @var mixed URL of published assets. False prevents asset publishing.
*/
public $baseScriptUrl=false;
/**
* Override CListView::cssFile to prevent CSS publishing
*
* @var mixed URL of published assets. False prevents asset publishing.
*/
public $cssFile=false;
/**
* Override CListView::run() to prevent registration of client script.
*/
public function run()
{
echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$this->renderContent();
echo CHtml::closeTag($this->tagName);
}
}
Thanks for the code Mike, but as I’ve commented on the bug report, the issue here is not how to derive a class, but whether this option should be available in the base class itself or not, and I think it should.
I can see no reason not to include it - it requires a very small modification (at most adding one variable and a check in registerClientScripts), would be completely backwards compatible, and doesn’t involve extending the base class to override methods that we may later have to update to reflect changes in the framework.
I myself would like some clean method of using my own customised version of the yiigridview.jquery.js file, so even better perhaps would be to have an attribute to allow us to give a custom jquery file name (although we would perhaps need a custom function name to call too), which would then allow us to include a custom file if we wish (which would then replace the default), leave it as it is (so the defaults are included) or even set it to false which could be taken to mean not including any javascript (like the cssFile property).