本文介绍了更新Yii gridView时'无法读取未定义的'ajaxType'属性'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

收到以下错误:未捕获的TypeError:无法读取未定义的属性'ajaxType'" .这是我的js代码

Got following error: "Uncaught TypeError: Cannot read property 'ajaxType' of undefined". Here's my js code

 $('document').ready(
    function () {
       $.fn.yiiGridView.update('new-orders');
                });

有趣的是,当我没有在 document.ready 上调用此函数,而是等待页面加载并从控制台调用它时,一切正常.但是当我在代码中调用它时,会出现此错误,然后当我尝试再次从控制台调用它时,我收到了相同的错误.这是我的小部件代码

What's interesting, when I'm not calling this function on document.ready, but waiting for page to load and calling it from console, everything works fine. but when I'm calling this in code, this error appears, and then when I'm trying to call it from console again, I'm receiving same error. Here's my widget code

<?php $this->widget('booster.widgets.TbGridView', array(
                'type'=>'striped bordered condensed',
                'ajaxUrl'=>array('/user/profile'),
                'dataProvider'=>$data,
                'id'=>'new-orders',
                'columns'=>array(
                      ....
                )));

推荐答案

我对这个框架一无所知,但这也许是个资产问题.您可以尝试使用:

I have no idea about this framework but perhaps it's an asset issue. You can try using instead:

$(window).on("load", function() {
  $.fn.yiiGridView.update('new-orders');
});

别忘了阅读 .ready() 有关此事件用法的文档并且您可能希望更仔细地查看您的资产.

Don't forget to read .ready()'s documentation about the usage of this event and you might want to have a closer look at your assets.

这篇关于更新Yii gridView时'无法读取未定义的'ajaxType'属性'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 10:50