2010-04-09 131 views
5

我使用jquery分頁插件進行分頁......如果有一個分頁插件,對我來說沒有問題......但是如果有兩個似乎是工作,但對方似乎並沒有太...這裏是我的代碼,在同一頁面中的兩個jquery分頁插件似乎沒有工作

<div id="PagerUp" class="pager"> 

</div><br /><br /><br /> 
    <div id="ResultsDiv"> 

</div> 
<div id="PagerDown" class="pager"> 

</div> 

我的jQuery有,

<script type="text/javascript"> 
     var itemsPerPage = 5; 
     $(document).ready(function() { 
      getRecordspage(0, itemsPerPage); 
      var maxvalues = $("#HfId").val(); 
      $(".pager").pagination(maxvalues, { 
       callback: getRecordspage, 
       current_page: 0, 
       items_per_page: itemsPerPage, 
       num_display_entries: 5, 
       next_text: 'Next', 
       prev_text: 'Prev', 
       num_edge_entries: 1 
      }); 
     }); 

</script> 

下面是我收到...

alt text http://img52.imageshack.us/img52/5618/pagerse.jpg

這兩部作品,但看pagerup選擇的頁面是3PagerDown顯示1 ....如何改變在jQuery的其他尋呼機回調事件尋呼機....

編輯: 使用MEF的想法似乎不工作...

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
    <script type="text/javascript" src="jquery.js"></script> 
    <link rel="Stylesheet" type="text/css" href="CSS/Main.css" /> 
     <script type="text/javascript" src="Javascript/jquery.pagination.js"> 
     </script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      $(".pager").pagination(300, { callback: pagecallback, 
       current_page: 0, 
       items_per_page: 5, 
       num_display_entries: 5, 
       next_text: 'Next', 
       prev_text: 'Prev', 
       num_edge_entries: 1 
      }); 
     }); 
    function pagecallback() { 
     var paginationClone = $("#Pagination > *").clone(true); 
     $("#Pagination2").empty(); 
     paginationClone.appendTo("#Pagination2"); 
    } 
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 

<div class="pager" id="pagination"> 
    <!-- the container for your first pagination area --> 
</div> 

<div id="results"> 
    <!-- the container where you show your results --> 
</div> 

<div class="pager" id="Pagination2"> 
    <!-- the container for your second pagination area --> 
</div> 
    </div> 
    </form> 
</body> 
</html> 

回答

12

因爲這似乎並沒有被正式支持,這裏是一個解決辦法(working demo)。

步驟1 創建您的HTML標記如下:

<div class="pagination" id="Pagination"> 
    <!-- the container for your first pagination area --> 
</div> 

<div id="results"> 
    <!-- the container where you show your results --> 
</div> 

<div class="pagination" id="Pagination2"> 
    <!-- the container for your second pagination area --> 
</div> 

步驟2的想法:
的想法是現在使用分頁插件像往常一樣與第一分頁格。但是,另外,我們希望每次頁面更改時都將第一個分頁div的所有內容複製到第二個分頁div。

步驟3捏捏pageSelect回調:
在回調函數的末尾添加以下行:

var paginationClone = $("#Pagination > *").clone(true); 
$("#Pagination2").empty(); 
paginationClone.appendTo("#Pagination2"); 

包括與.clone布爾參數(withDataAndEvents)這是非常重要的調用,否則您的分頁副本將不會有任何點擊事件。

現在,每次點擊分頁元素(不管它是原始還是副本),頁面都會更改,分頁元素也會相應更新。

+0

@mef它似乎不適合我... – 2010-04-12 11:55:36

+0

@Pandiya Chendur:這絕對有效。仔細檢查身份證等... – Leo 2010-04-12 11:59:22

+0

@Mef看看我編輯的部分我的問題,這就是我使用的... – 2010-04-12 12:18:53

2

也許這不是你所希望看到的答案,但有一個爲jQuery的分頁插件,建議具有同一頁上的兩個尋呼機功能請求是n加時賽當前實現支持:

http://plugins.jquery.com/node/11825