views:

279

answers:

3

I am trying my hardest to learn jQuery with the "Learning Jquery 1.3 Book from Packt".

I am following the code to the letter but I am finding it hard to get the code working.

I am trying a simple Page Pagination with the following code but I am having no luck can any one tell me why and offer some advice.

Thanks.

$(document) .ready(function() {
    $('table.paginated').each(function() {
        var currentPage = 0;
        var numberPage = 5;
        var $table = $(this);
        $table.find('thead tr').hide()
          .slice(currentPage * numPerPage, (currentPage + 1) * numPerPage)
          .show();
    });
});

My Table tabs are :

<table id="tablesorter" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
      <thead>
       <tr>  
          <th>Ref</th>
          <th>Date</th>
          <th>Company</th>
          <th>Operator</th>
          <th>Boxes</th>
          <th>Network</th>
          <th>Quote Accept</th>
          <th>Term Accept</th>
          <th>Credit Check</th>
          <th>Expiry</th>
       </tr>
      </thead>
       <tbody>
A: 

Does your table definitely have the correct definition... i.e.

<table>
    <tbody>
        <tr>...</tr>
        <tr>...</tr>
        <tr>...</tr>
        <tr>...</tr>
    </tbody>
</table>

The only problem that pops out at me is that it relies on the rows being nested in a tbody tag.

Sohnee
Just edited my question with my table tags
Oliver Bayes-Shelton
Have you also sorted that bad syntax problem?
jakeisonline
+1  A: 

First line

$(document) .ready(function() { // Bad Syntax

Remove that space!

$(document).ready(function() { // Good Syntax
jakeisonline
+2  A: 

This may seem obvious, but have you loaded the tablesorter and tablesorter pager plugin?

<script type="text/javascript" src="/path/to/jquery.tablesorter.min.js"></script> 
<script type="text/javascript" src="/path/to/jquery.tablesorter.pager.js"></script>

or are you not using these plugins? I just assumed you were from the table id.

R. Bemrose
Im not no , Do you think thats the issue
Oliver Bayes-Shelton