Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 747705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:14:10+00:00 2026-05-14T14:14:10+00:00

I’m using the jQuery tablesorter plugin to sort a table, which assigns .click() handlers

  • 0

I’m using the jQuery tablesorter plugin to sort a table, which assigns .click() handlers to the <th>s in the table. Since my table has alternating colors for each column, I’ve built a simple fix_table_colors(identifier) function that does as it should when I call it manually using Firebug. I would like, however, to have that automatically called after a sort.

To do this, I decided to retrieve the .click() handler from the <th>s, and assign a new handler that simply calls the previous handler, followed by fix_table_colors().

(This SO question is similar, but uses standard onClick() attributes, which won’t work here.)

From the accepted answer to this question, I have created the following code:

$(document).ready(function() {
    $("table.torrents").tablesorter({
        debug: true,
        headers: {
            1: { sorter: 'name' },
            2: { sorter: 'peers' },
            3: { sorter: 'filesize' },
            4: { sorter: 'filesize' },
            5: { sorter: 'filesize' },
            6: { sorter: 'ratio' }
        }
    });

    $('table.torrents thead th').each(function() {
        var th = $(this);
        var clickHandler = th.data('events').click[0];
        th.click(function() {
            clickHandler();
            fix_table_colors('table.torrents');
        });
    });
});

While this is conceptually correct, clickHandler doesn’t appear to actually be a function, and so I cannot call it.

With a bit more digging in Firebug, I found that click[3] appears to hold the function I’m looking for (and click[10] my new one). I get an ‘e is undefined’ error on line 2 of tablesorter.min.js when using that, though.

Am I even going down the right path? I have a feeling that with what I’ve found so far, I can make this work, but it’s going to be much uglier than I would expect it needs to be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:14:11+00:00Added an answer on May 14, 2026 at 2:14 pm

    How about binding to the sortEnd (http://tablesorter.com/docs/example-triggers.html) event like so?

    $(document).ready(function() {
        $("table.torrents").tablesorter({
            debug: true,
            headers: {
                1: { sorter: 'name' },
                2: { sorter: 'peers' },
                3: { sorter: 'filesize' },
                4: { sorter: 'filesize' },
                5: { sorter: 'filesize' },
                6: { sorter: 'ratio' }
            }
        });
    
        $("table.torrents").bind("sortEnd",function() {
            fix_table_colors('table.torrents');
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 475k
  • Answers 475k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you already have a sorted list, which is sorted… May 16, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer Taking Gilbert's advice into account, I decided to create my… May 16, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer First of, *args is always a list. You want to… May 16, 2026 at 4:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.