Jquery Object doesn't support this property or method

十年热恋 提交于 2019-12-24 14:00:39

问题


I have the following in my JSP page and I am getting error

Message: Object doesn't support this property or method

at $("#projects").dataTable({

If I remove

.makeEditable({
                   sAddURL: "addController"
                              });

then there are no js errors, how can I resolve this issue?

JS Code

$(document).ready(function () {
    $("#projects").dataTable({ // error here
        "bServerSide": true,
        "sAjaxSource": "mycontroller",
        "bProcessing": true,
        "sPaginationType": "full_numbers",
        "bJQueryUI": true
    }).makeEditable({
        sAddURL: "addController"
    });
});

and I have the following js files

 <script src="scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
 <script src="scripts/jquery.dataTables.editable.js" type="text/javascript">
 </script>
 <script src="scripts/jquery.jeditable.js" type="text/javascript"></script>
 <script src="scripts/jquery.validate.js" type="text/javascript"></script>
 <script src="scripts/jquery-ui.js" type="text/javascript"></script>

 <script src="scripts/jquery.js" type="text/javascript"></script>
 <script src="scripts/jquery.dataTables.min.js" type="text/javascript"></script>

回答1:


Well, @Guffa already answered sufficiently. You can accept his answer if you want. :)

I just want to add another thing, which is the conflict between jQuery versions. It's because if you use plugins that are not compatible with the jQuery version you've included (happened to me some time). You can add another jQuery version that is compatible with that plugin, along with using jQuery.noConflict()




回答2:


You are including the jQuery library twice, possibly using two different versions. scripts/jquery-1.4.4.min.js and scripts/jquery.js are both the jQuery library.

The second will replace the first, and in the process you lose all the plugins that were added to the first instance. As you end up with only the dataTables plugin, the makeEditable call won't work. It's not the dataTable method that doesn't exist, the error is just reported on that line because the statement starts there.

Remove the second include of the jQuery library. You might also need a different version of the dataTables plugin, if it's not compatible with the 1.4.4 version of the jQuery library. Alternatively use a later version of jQuery.




回答3:


Based on what you've provided, I can only assume that $('#projects').dataTable is being executed before jquery.dataTables.min.js is loaded.



来源:https://stackoverflow.com/questions/15759137/jquery-object-doesnt-support-this-property-or-method

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