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.更改脚本引用的顺序。不起作用。
最佳答案
脚本顺序:
从您的示例来看,可能是脚本加载顺序不正确。 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
jeditable
是 dataTables.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/