javascript - Datatable makeEditable() 不是一个函数?

标签 javascript jquery datatable datatables

angular.js:11594 TypeError: undefined is not a function
at ini_table (http://localhost/ferpa-quiz-client/assets/js/controller.js:127:15)
at HTMLDocument.<anonymous> (http://localhost/ferpa-quiz-client/assets/js/controller.js:26:5)
at j (http://localhost/ferpa-quiz-client/bower_components/jquery/dist/jquery.min.js:2:26911)
at Object.k.add [as done] (http://localhost/ferpa-quiz-client/bower_components/jquery/dist/jquery.min.js:2:27220)
at n.fn.ready (http://localhost/ferpa-quiz-client/bower_components/jquery/dist/jquery.min.js:2:29326)
at new <anonymous> (http://localhost/ferpa-quiz-client/assets/js/controller.js:21:16)
at e (http://localhost/ferpa-quiz-client/bower_components/angular/angular.min.js:37:96)
at Object.instantiate (http://localhost/ferpa-quiz-client/bower_components/angular/angular.min.js:37:207)
at http://localhost/ferpa-quiz-client/bower_components/angular/angular.min.js:76:267
at link (http://localhost/ferpa-quiz-client/bower_components/angular-route/angular-route.min.js:7:248) <div ng-view="" class="ng-scope">

这是我收到的错误,blow 是我的代码。删除 .makeEditable() 后一切正常。

$("#questiontable").DataTable(
            {
                bAutoWidth: true,
                bProcessing: true,
                ajax: '../api/ferpa-quiz/public/getallquestion',
                sDom: '<"$grid-toolbar"sF>tr<"dataTables-footer"ilp>',
                iDisplayLength: 5,

                aoColumns: [
                    { 
                        mData: 'QUESTION',
                        sTitle: "QUESTION"

                    }


                ]

            }
        ).makeEditable();

HTML

<script src="bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<link href="bower_components/datatables/media/css/jquery.dataTables.min.css" rel="stylesheet"/>
<script src="bower_components/ediTable/jquery.dataTables.editable.js"></script>
<script src="bower_components/jeditable/js/jquery.jeditable.js"></script>

我尝试过的事情: 1. 将“D”切换为“d”。都不起作用 2.更改脚本引用的顺序。不起作用。

JQuery 1.10.2 Datatable makeEditable() is Not a function

最佳答案

脚本顺序:

从您的示例来看,可能是脚本加载顺序不正确。 dataTables 上给出的示例网站按以下顺序加载脚本:

jquery.min.js
jquery.dataTables.min.js
jquery.jeditable.js
jquery-ui.js
jquery.validate.js //not sure this one is strictly needed
jquery.dataTables.editable.js

jeditabledataTables.editable 调用的必需脚本。这也意味着 jeditable 需要在 dataTables.editable 之前加载。

Angular JS 中的 JQuery:

我对 Angular js 不太熟悉,但是从他们的文档来看......

Does Angular use the jQuery library?

Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

而且,JQLite 与 JQuery 不一样...dataTable 需要 JQuery。注:

Angular 1.3 only supports jQuery 2.1 or above. jQuery 1.7 and newer might work correctly with Angular but we don't guarantee that.

因此,版本也很重要。

关于javascript - Datatable makeEditable() 不是一个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27843664/

相关文章:

c# - 数据表Select语句问题

javascript:访问闭包中的函数

javascript - 将 HTML 元素的内容输出到控制台

jquery - 如何在jquery中设置禁用按钮的事件?

javascript - 如何使用上下文变量将信息传递给 JavaScript 中的 Promise 函数?

javascript - jQuery Sortable 不能拖放

php - 数据表按数字字段排序

javascript - JavaScript 中两个相似代码块的不同行为

javascript - javascript promise finally block 中的异步操作

C# 更新 mySQLDateTime 数据表