1

I'm getting the following error when I try to access a page that's supposed to display a table with the jquery plugin from datatables.net:

Microsoft JScript runtime error: Object doesn't support property or method 'dataTable'

Here is where I'm referencing various scripts/plugins on my page:

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js" ></script>
<script type="text/javascript" src="Script/jquery.tools.min.js"></script>
<script type="text/javascript" src="Script/superfish.js"></script>
<script src="Script/jquery.MultiFile.js" type="text/javascript"></script>
<script type="text/javascript" src="Script/supersubs.js"></script>

Here is where I'm trying to call the dataTable function on the table (with id mod123):

<script type="text/javascript">
    $(document).ready(function() {
        $('#mods123').dataTable();
    });
</script>

I have a thead and tbody tag within my table, but when I build the project and run it locally and navigate to the page, it gives me this error. When I go to the page in different browser, the error doesn't show of course, but the table that I'm trying to affect is not changed in any way.

When I look at the page in Firebug, it gives me the following error: $("#mods123").dataTable is not a function

Chrome's debugger says "Uncaught TypeError: Object [object Object] has no method 'dataTable'

Any ideas?

3
  • Is your ID "mod123" or "mods123"? You used both in your post. Commented Apr 11, 2012 at 22:07
  • I put together a barebones example that seems to work just fine. Check your URLs, IDs, etc. Commented Apr 11, 2012 at 22:14
  • It's mods123, sorry, but it's that way in the selector as well as the table tag. I just tried the datables debugger and it tells me that datatables isn't available on my page, despite my seeing the reference to it when I view source. Argh! Commented Apr 11, 2012 at 23:17

2 Answers 2

2

It looks like your version of jQuery is not compatible with dataTables. Try using the version of jQuery that came with dataTables. I think it is jQuery 1.7.1.

Sign up to request clarification or add additional context in comments.

6 Comments

I tried barebones examples down to jQuery 1.2.6 and they all worked, but I did not specifically try 1.6.2. Maybe there's a compatibility issue with that version.
Tried 1.7.1, and also tried the non-minified version of datatables, but nothing is working.
From the dataTable's website: "The error means that either the DataTables plug-in hasn't been loaded, jQuery has been loaded again (thus overwriting the old one) or $ is not jQuery."
@Levi Remove first jQuery reference and move jQuery tools script line above the dataTable script line. Sounds like jQuery($) might be getting loaded twice. Once here: <script type="text/javascript" src="ajax.aspnetcdn.com/ajax/jquery/…> And another here: <script type="text/javascript" src="Script/jquery.tools.min.js"></script> if jQuery is included in the tools.
@PaulS, thanks, yeah, as you see below, I was able to get it working by removing jquery tools, but thanks for the tip, I had no idea that jquery was included IN jquery tools! Your suggestion worked and now I don't have to deal with removing jquery tools...
|
1

Ok, well, it looks like it was actually a conflict between datatables and jquery tools. When I removed the reference to jquery tools, it worked!

I don't think we're currently using jquery tools, so I may be ok, but if not, how can I avoid this conflict? I couldn't find a reference to this specifically, so I wonder if it used to be for an older version of tools but they've fixed it? But again, I can't seem to find any mention...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.