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 8039125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:28:18+00:00 2026-06-05T03:28:18+00:00

Here’s the thing: file a.php contains jQuery Tablesorter table. This is the Tablesorter code:

  • 0

Here’s the thing: file a.php contains jQuery Tablesorter table.
This is the Tablesorter code:

 $("#feedsTable thead").live("click", function() {
       $("#feedsTable").tablesorter({
                widthFixed : true,
                dateFormat : "uk",
            }).tablesorterPager({
                container : $("#pager"),
                positionFixed : false
            });
        });

Slightly stripped table HTML code:

<div id="tablica">
    <article class="module width_full">
        <div id="pager">
            <form>
                [snip]tablesort pager stuff... 
            </form>
        </div>
        <table id="feedsTable" class="tablesorter" cellspacing="0">
            <thead>
                <tr>
                    [snip]table header row...
                </tr>
            </thead>
            <tbody> ... PHP printed table data

Also, file a.php contains refresh link, which, when clicked, calls b.php file which contains following code: $("#tablica").load("a.php #tablica"); (basically, b.php prints table with new elements and then replaces the old table with the new one using the load function).

Of course, I must use either jQuery live or delegate (having some kind of problems with this one, just can’t get Tablesorter to work, so I’m using live instead) function instead of (document).ready because once the load code is executed, Tablesorter will not work with the new table data.

But the problem is that when I use jQuery live() function, I need to click twice to be able to use the Tablesorter plugin. It’s like the first click only “activates” the plugin, and then, when table header is clicked for 2nd time, table is sorted and it works great.

In a.php, I can add this code

$(document).ready(function() {
    $("#feedsTable thead").click();
});

and it will “activate” the plugin and first user’s click on the table header will sort the table. But if I add $("#feedsTable thead").click(); to the b.php file and click refresh link, this “hack” does not work, and again two clicks are needed to be able to use Tablesorter plugin after the table with new data is loaded.

Basically, the question is: I would like Tablesorter to work on first click when using jQuery live, and not only on second. How to fix that?

Any help would be much appreciated!

Thanks.

  • 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-06-05T03:28:20+00:00Added an answer on June 5, 2026 at 3:28 am

    So, delegate won’t work because it is targeting the table inside of #tablica which has all of its contents completely replaced by the load function. Delegate needs an “anchor” element to detect a bubbling event whereas live uses the document, I think. So, the way it is written, when the user clicks anywhere in the thead, tablesorter will initialize. Now a second click will actually sort the column because tablesorter is active.

    Anyway, the solution would be to initialize tablesorter within the load callback function. So remove the live function completely and try just this:

    $("#tablica").load("a.php #tablica", function(){
        $("#feedsTable").tablesorter({
            widthFixed : true,
            dateFormat : "uk",
        }).tablesorterPager({
            container : $("#pager"),
            positionFixed : false
        });
    });
    

    Now when the user clicks on the table header it will sort because tablesorter is initialized immediately after the content is loaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is what I am trying to achieve in PHP: I have this string:
Here's a coding problem for those that like this kind of thing. Let's see
Here is my code: echo '<table class=class1><tbody>'; while ($row1=mysql_fetch_array($result1)){ echo '<tr><td>'.$row1['firstname'].'</td><td>'.$row1['lastname'].'</td></tr>'; } echo '</tbody></table>';
Here's my client-side jQuery code: $.ajaxSetup ({ contentType: application/json, datatype: 'json' }); $.ajax({ type:
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
Here's what I'm doing. I want to upload multipart file via Ajax to my
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here's what my table TheTable looks like ColA | ColB | ColC ------+-------+------ abc

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.