猿问

未捕获的 TypeError: $(...)。jsGrid 不是一个函数

在我的页面中,我正在尝试创建一个 jsgrid 表,我认为没有错,因为我以正确的方式导入了东西,但它给了我这个;

未捕获的 TypeError: $(...)。jsGrid 不是函数错误

是不是有什么问题,因为我没有看到初始化表的任何错误?

这是我的代码:

您不需要该单击功能,因此您可以通过这种方式修改您的代码。


<script>

    function onUpdate() {


      var tableData = $("tr.table")

        .children("td")

        .map(function () {

          return $(this).text();

        })

        .get();


      if( tableData[7] === 2) {

         console.log("if statement");

      }

    }

  </script>


肥皂起泡泡
浏览 78回答 2
2回答

九州编程

问题是<script&nbsp;src="assets/vendors/js/vendor.bundle.base.js"></script>这些脚本的函数名称与 jsGrid 函数名称重叠,因此阻止了浏览器/javascript 正确读取函数,我将这些脚本移动到需要它们的地方,所以现在没有问题,感谢您的所有帮助和努力。

牧羊人nacy

假设您的文件都是正确的,我建议将您的jquery函数调用包装在.这样,只有在 DOM 准备好通过 Javascript 进行编辑时,它们才会运行。document.ready<script>$(document).ready(function(){&nbsp; &nbsp; $("#brands_table").html("asd");&nbsp; &nbsp; $("#brands_table").jsGrid({&nbsp; &nbsp; &nbsp; &nbsp; width: "100%",&nbsp; &nbsp; &nbsp; &nbsp; height: "400px",&nbsp; &nbsp; &nbsp; &nbsp; filtering: true,&nbsp; &nbsp; &nbsp; &nbsp; inserting:true,&nbsp; &nbsp; &nbsp; &nbsp; editing:true,&nbsp; &nbsp; &nbsp; &nbsp; sorting:true,&nbsp; &nbsp; &nbsp; &nbsp; paging:true,&nbsp; &nbsp; &nbsp; &nbsp; autoload:true,&nbsp; &nbsp; &nbsp; &nbsp; pageSize:10,&nbsp; &nbsp; &nbsp; &nbsp; pageButtonCount:5,&nbsp; &nbsp; &nbsp; &nbsp; deleteConfirm:"Silmek istediğinize emin misiniz?",&nbsp; &nbsp; &nbsp; &nbsp; controller:{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loadData: function (filter) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return $.ajax({&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type:"GET",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url:"assets/php/getbrands.php",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data:filter&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; fields:[&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name:"id",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type:"hidden",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; css:'hide'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name:"name",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type:"text",&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:150,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validate:"required"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: "control"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; ]&nbsp; &nbsp; });&nbsp; &nbsp; });</script>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答