Solved

jQuery Tablesorter plugin not working

Posted on 2011-09-30
6
1,590 Views
Last Modified: 2012-05-12
Hi,

I'm trying to implement jQuery tablesorter plugin in Coldfusion 9 pages. I can implement it fine on a page without any other .js file includes but when I try to use it in a .cfm that has other .js includes, it doesn't work. I make sure that jQuery is the first .js that is loaded and the css files are all in the right order. But the css does not fully load nor does the .js.

In firebug, I get the following error:

$("#myTable").tablesorter is not a function

I've been struggling with this for almost a day but nothing seems to work. Could someone who's implemented this and had similar issues point me in the right direction?
0
Comment
Question by:roger_v
  • 3
  • 3
6 Comments
 
LVL 6

Expert Comment

by:ventaur
ID: 36893895
Are you making sure that your call to add table sorter to your table is after the DOM is loaded?

$(function() {
  $("#myTable").tablesorter;
});

Open in new window

0
 
LVL 6

Accepted Solution

by:
ventaur earned 500 total points
ID: 36893903
...also, include parentheses when calling tablesorter.

$(function() {
  $("#myTable").tablesorter();
});

Open in new window

0
 
LVL 1

Author Comment

by:roger_v
ID: 36894147
@ventaur:

Yes, I have document.ready before I call the tablesorter function. And I do have paren after tablesorter like so: tablesorter();

Here is my .cfm page that first includes another .cfm file that has all the css and .js files in it.

<!---test2.cfm--->
<head>
<cfinclude template="UI_Sorting.cfm">
  <script type="text/javascript">
        $(document).ready(function() {
            $("#myTable").tablesorter();
       });
 </script>
</head>

<body onload="SetPermissions();">


<!---UI_Sorting.cfm--->
<style type="text/css">
            @import url("../styles/tablesorter.css");
            @import url("../styles/jquery.tablesorter.pager.css");
            @import url("../styles/jquery-ui-1.8.14.custom.css");
            
</style>
<script src="../jquery/jquery-1.5.1.min.js" language="javascript"></script>
<script src="../jquery/jquery-ui-1.8.14.custom.min.js" language="javascript"></script>
<script src="../jquery/jquery.tablesorter.min.js" language="javascript"></script>
<script src="../jquery/jquery.tablesorter.pager-mod.js" language="javascript"></script>
<!---xxxx--->

Now, I do have another js function that is run on the onload of the body. Could that be a problem?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:roger_v
ID: 36894157
Nope, I removed the body onload js function but still get this error:

$("#myTable").tablesorter is not a function


I know that jquery is being loaded because I can invoke an alert box in the document.ready function and it works fine. It's just the table sorter function that is a problem.
0
 
LVL 1

Author Closing Comment

by:roger_v
ID: 36894209
Oops, I'm a total idiot on this! I was loading the jquery minified file twice! Thanks for your input though!
0
 
LVL 6

Expert Comment

by:ventaur
ID: 36894591
It happens. Glad you figured it out.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now