|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 3 | + <head> |
| 4 | + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 5 | + <title>Pagination Demo I - Simple pagination</title> |
| 6 | + <link rel="stylesheet" href="../pagination.css" /> |
| 7 | + <link rel="stylesheet" href="demo.css" /> |
| 8 | + <script type="text/javascript" src="lib/jquery.min.js"></script> |
| 9 | + <script type="text/javascript" src="../jquery.pagination.js"></script> |
| 10 | + |
| 11 | + <script type="text/javascript"> |
| 12 | + |
| 13 | + // This is a very simple demo that showing the options for handling a single page. |
| 14 | + // Default of the option show_if_single_page is false. |
| 15 | + // So you only have to call the plugin with this option if you feel the need |
| 16 | + // to show the pagination even if there is only one single page. |
| 17 | + // Otherwise just leave it out. |
| 18 | + |
| 19 | + /** |
| 20 | + * Callback function that displays the content. |
| 21 | + * |
| 22 | + * Gets called every time the user clicks on a pagination link. |
| 23 | + * |
| 24 | + * @param {int} page_index New Page index |
| 25 | + * @param {jQuery} jq the container with the pagination links as a jQuery object |
| 26 | + */ |
| 27 | + function pageselectCallback(page_index, jq){ |
| 28 | + var new_content = jQuery('#hiddenresult div.result:eq('+page_index+')').clone(); |
| 29 | + $('#Searchresult').empty().append(new_content); |
| 30 | + return false; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Initialisation function for pagination |
| 35 | + */ |
| 36 | + function initPagination() { |
| 37 | + // count entries inside the hidden content |
| 38 | + var num_entries = jQuery('#hiddenresult div.result').length; |
| 39 | + // Create content inside pagination element |
| 40 | + $("#Pagination").pagination(num_entries, { |
| 41 | + callback: pageselectCallback, |
| 42 | + items_per_page:1, // Show only one item per page |
| 43 | + //show_if_single_page:true // Show if there is only one single page |
| 44 | + }); |
| 45 | + } |
| 46 | + |
| 47 | + // When document is ready, initialize pagination |
| 48 | + $(document).ready(function(){ |
| 49 | + initPagination(); |
| 50 | + }); |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + </script> |
| 55 | + </head> |
| 56 | + <body> |
| 57 | + <h1>jQuery Pagination Plugin Demo</h1> |
| 58 | + |
| 59 | + <h2>Show Pagination if there is only one single page</h2> |
| 60 | + <div id="Pagination"></div> |
| 61 | + <div id="Searchresult" style="clear:both;"> |
| 62 | + <p>Page 1</p> |
| 63 | + </div> |
| 64 | + |
| 65 | + <!-- Container element for all the Elements that are to be paginated --> |
| 66 | + <div id="hiddenresult" style="display:none;"> |
| 67 | + <div class="result"> |
| 68 | + <p>Page 1</p> |
| 69 | + </div> |
| 70 | + <!-- |
| 71 | + <div class="result"> |
| 72 | + <p>Page 2</p> |
| 73 | + </div> |
| 74 | + --> |
| 75 | + </div> |
| 76 | + |
| 77 | + <div id="footer"> |
| 78 | + Copyright © 2010 by <a href="http://www.d-scribe.de/">describe europe Ltd.</a>. |
| 79 | + </div> |
| 80 | + </body> |
| 81 | +</html> |
0 commit comments