我收到此错误。看起来它没有看到我的 clistview 的 id,它甚至没有出现在检查中,这很奇怪。
但我给了它一个 id..
<?php $this->widget('zii.widgets.CListView', array(
'id'=>'how',
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'template'=>'{items} {pager}',
'pager' => array(
'class' => 'ext.infiniteScroll.IasPager',
'rowSelector'=>'.left-pwrapper',
'listViewId' => 'how',
'header' => '',
'loaderText'=>'Loading...',
'options'=>array('onRenderComplete'=>'js:function () {
$.each($(".left-pwrapper"), function(){
if(typeof $.fn.yiiListView.settings["\'"+$(this).attr("id")+"\'"]=="undefined")
$(this).yiiListView();
});
}')),
)); ?>
当我去元素检查时,错误显示在这里:
$.fn.yiiListView.update = function(id, options) {
var customError,
settings = $.fn.yiiListView.settings[id];
if (options && options.error !== undefined) {
customError = options.error;
delete options.error;
}
options = $.extend({
type: settings.ajaxType,
url: $.fn.yiiListView.getUrl(id),
[[[Cannot read property 'ajaxType' of undefined ]]]
我尝试了下面的代码,它对我有用。你可以尝试一下😊
<?php $listView = $this->widget('zii.widgets.CListView', array(...)); ?>
<?php
$id = $listView->htmlOptions['id'];
$options = $listView->registerClientScript();
?>
<script type='text/javascript'>
/*<![CDATA[*/
jQuery(function($) {
jQuery('#<?php echo $id; ?>').yiiListView(<?php echo $options; ?>);
});
/*]]>*/
</script>
您所要做的就是设置 'ajaxUpdate' => true
$this->widget('zii.widgets.CListView', array(
'id' => "test",
'ajaxUpdate' => true,
'dataProvider'=>$model->search(),
'itemView'=>'_testView',
));
然后
$.fn.yiiListView.update('test');
它就像魔法一样..
使用该功能时
$.fn.yiiListView.update('id');
请勿使用#
错误:
$.fn.yiiListView.update('#myList');
正确:
$.fn.yiiListView.update('myList');