Reputation: 14731
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>
Upvotes: 1
Views: 17026
Reputation: 14827
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()
Upvotes: 2
Reputation: 700192
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.
Upvotes: 6
Reputation: 2879
Based on what you've provided, I can only assume that $('#projects').dataTable
is being executed before jquery.dataTables.min.js
is loaded.
Upvotes: 0