0
即時通訊嘗試讓主幹/下劃線分頁正常工作。它在init和next/prev導航上工作正常。骨幹分頁當前頁面錯誤
但是當我嘗試在運行時設置當前頁面時,它會跳出並呈現錯誤的頁碼。只有當我將當前頁面設置爲8以上時纔會出錯。8以下的每個工作都可以正常工作。這是我的模板,一次只能顯示10個頁碼,積分爲 Rida BENHAMMANE!
模板:
<script type="text/template" id="pagination_template">
<section class="pagination">
<ul>
<li>
<div class="paging prev">◄</div>
</li>
<%
var renderPages;
for (var i = 0; i <= pages-1; i++) {
renderPages = false;
if (pages < 10) {
renderPages = true;
} else {
if (current <= 5) {
if (i < 10) {
renderPages = true;
}
} else if (current <= pages - 5) {
if ((current - 5) < i && (current + 5) > i) {
renderPages = true;
}
} else {
if ((pages - 9) < i) {
renderPages = true;
}
}
};
if(renderPages) { %>
<li>
<a href="#" data-offset="<%= i*9 %>" data-page="<%= i %>">
<%= i+1 %>
</a>
</li>
<% }
}
%>
<li>
<div class="paging next">►</div>
</li>
</ul> <br><br>
total pages <%= pages %>
</section>
</script>
這裏是功能的變化當前頁面,並呈現navigaton。 當前頁面被設置爲clicked元素的數據屬性。
updatePageNum: function() {
var self = this;
self.totalModel.fetch({
success:function(model,response) {
var total = response.data;
var p = total/self.perPage;
var r = total-Math.round(p)
self.maxPage = Math.ceil(p);
self.pagination = _.template($("#pagination_template").html(), {
pages:self.maxPage,
current:self.currentPage
});
}
});
},
任何人都可以幫忙嗎?
只是一個想法,但嘗試用'parseInt()'包裝你的數字。 – Puigcerber
當然你完全正確。謝謝! – user3122094