Catherine
Catherine

Reputation: 129

JQuery tablesorter disable column

I'm trying to disable the first column of a table with the JQuery plugin tablesorter 2.0.5

While it does disable, I can't sort other columns properly anymore. I can only click once on a column and then have to click once on another column to be able to click again (still only once), as described in this post.

I have followed this first example and this other example

and here's the code I include in the php view

echo '<script type="text/javascript" language="JavaScript">

$(document).ready(function() { 
    $("table").tablesorter({ 
    headers: { 
        0: {sorter: false}
    } 
    }); 
});

</script>';

Upvotes: 1

Views: 1755

Answers (1)

Mottie
Mottie

Reputation: 86403

Ok, here is a jsFiddle demo for you

Your code looks okay, except that the language attribute is no longer necessary, so I'm not sure where you might be having your problem.

echo '<script type="text/javascript">
$(document).ready(function() { 
    $("table").tablesorter({ 
    headers: { 
        0: {sorter: false}
    } 
    }); 
});
</script>';

Things to check would be:

  1. Ensure there is only one copy of jQuery running
  2. Ensure that the tablesorter script is loaded after jQuery (the script tag should be after it)
  3. Make sure that table is the correct target for tablesorter. You may need to add an ID or class name to the table then target it, e.g. $("#mytable").
  4. Check your page for errors - press F12, go to the console then reload the page.

Upvotes: 1

Related Questions