fn.yiiListView.update 无法读取未定义的属性“ajaxType”

问题描述 投票:0回答:4

我收到此错误。看起来它没有看到我的 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 yii
4个回答
0
投票

我已经看到了thisthisthis问题的答案,但没有一个解决了我的问题。

为我解决的问题是在我调用

ajaxUpdate
的 js 调用中设置
yiiListView
update
选项,如下所示:

$(element).yiiListView({
    'ajaxUpdate': [
        '1', element
    ]
});

$.fn.yiiListView.update(element, {
    //...
});

0
投票

我尝试了下面的代码,它对我有用。你可以尝试一下😊

  1. 将 $listView 变量分配给 $this->widget
<?php $listView = $this->widget('zii.widgets.CListView', array(...)); ?>
  1. 在包含列表视图的视图末尾添加代码
<?php
    $id = $listView->htmlOptions['id'];
    $options = $listView->registerClientScript();
?>
<script type='text/javascript'>
    /*<![CDATA[*/
    jQuery(function($) {
        jQuery('#<?php echo $id; ?>').yiiListView(<?php echo $options; ?>);
    });
    /*]]>*/
</script>

0
投票

您所要做的就是设置 'ajaxUpdate' => true

$this->widget('zii.widgets.CListView', array(
    'id' => "test",
    'ajaxUpdate' => true,
    'dataProvider'=>$model->search(),
    'itemView'=>'_testView',
    ));

然后

$.fn.yiiListView.update('test');

它就像魔法一样..


-2
投票

使用该功能时

$.fn.yiiListView.update('id');

请勿使用#

错误:

 $.fn.yiiListView.update('#myList');

正确:

$.fn.yiiListView.update('myList');
© www.soinside.com 2019 - 2024. All rights reserved.