Solved

jQuery Tablesorter plugin not working

Posted on 2011-09-30
6
1,678 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 
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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

695 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