0

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>

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Im not no , Do you think thats the issue
@OliverBayes-Shelton Well if they are needed, then I'd say not including them is a big problem. ;-)
1

First line

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

Remove that space!

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

Comments

0

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.

1 Comment

Have you also sorted that bad syntax problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.