jQuery dataTables makeEditable() is not a function

核能气质少年 提交于 2019-12-19 09:28:12

问题


I'm new to Datatables and I'm trying to make the table editable, but I keep getting this error:

TypeError: $(...).dataTable(...).makeEditable is not a function

My jQuery script looks like this:

    $(document).ready( function () {
    var oTable = $('#data_table_wrapper').dataTable({
        "sDom": 'R<"H"lfr>t<"F"ip<',
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "aoColumn": [
                { "bVisible": true },
                { "bVisible": true },
                { "bSortable": false },
                    ]       
    }).makeEditable({
        sUpdateURL: "/abc.php"
    });
});

I am including these files:

jquery-1.9.1.min.js
jquery.dataTables.min.js
jquery.jeditable.js
jquery.dataTables.editable.js
jquery-ui.js
jquery.validate.js

All links to these files work correctly. Can anyone give me some advice, please? Why do I keep getting that error?


回答1:


The imports have to be in certain order:

jquery.min.js

jquery-ui.min.js

jquery.dataTables.min.js

jquery.jeditable.js

jquery.dataTables.editable.js

jquery.validate.js

After fixing this, update to latest versions fixed the problem!




回答2:


For jQuery version 1.9.1 jQuery datatable won't work. Try using jQuery version 1.7.1 instead.




回答3:


My situation was:

(jQuery 3.x)

from jQuery DataTables website I had following:

<script>
    $(element).DataTable().makeEditable();
</script>

So - at first I had to change "DataTable" to "dataTable" giving:

<script>
    $(element).dataTable().makeEditable();
</script>

Then it threw the error (in jquery.dataTables.editable.js): TypeError: $(...).live is not a function. Which I fixed according to this topic jQuery 1.9 .live() is not a function :

line 655:

//$(".table-action-deletelink", oTable).live("click", function (e) {
$(oTable).on("click", ".table-action-deletelink", function (e) {


来源:https://stackoverflow.com/questions/14725091/jquery-datatables-makeeditable-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!