Solved

jQuery Tablesorter plugin not working

Posted on 2011-09-30
6
1,564 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
Comment Utility
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
Comment Utility
...also, include parentheses when calling tablesorter.

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

Open in new window

0
 
LVL 1

Author Comment

by:roger_v
Comment Utility
@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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:roger_v
Comment Utility
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
Comment Utility
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
Comment Utility
It happens. Glad you figured it out.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now