implement pagination (js)

This commit is contained in:
Sanj 2011-09-01 02:22:40 +05:30
parent 1b46aa5efa
commit cce48f4a18

View File

@ -13,6 +13,34 @@ $(function() {
map.setCenter(center, 4); map.setCenter(center, 4);
$('.first').click(function() {
$('#page_no').val('1');
$('#searchForm').submit();
});
$('.last').click(function() {
var lastPage = parseInt($('#totalPages').text());
$('#page_no').val(lastPage);
$('#searchForm').submit();
});
$('.next').click(function() {
var currPage = parseInt($('#page_no').val());
var lastPage = parseInt($('#totalPages').text());
if (currPage < lastPage) {
$('#page_no').val(currPage + 1);
$('#searchForm').submit();
}
});
$('.previous').click(function() {
var currPage = parseInt($('#page_no').val());
if (currPage > 1) {
$('#page_no').val(currPage - 1);
$('#searchForm').submit();
}
});
$('#searchForm').submit(function(e) { $('#searchForm').submit(function(e) {
e.preventDefault(); e.preventDefault();
var bbox = map.getExtent().toBBOX(); var bbox = map.getExtent().toBBOX();
@ -26,7 +54,8 @@ $(function() {
'q': search_term, 'q': search_term,
'srid': 3785, 'srid': 3785,
'threshold': 0.5, 'threshold': 0.5,
'count': 20 'count': 20,
'page': $('#page_no').val()
}, function(features) { }, function(features) {
if ($('.mapListSection').css("opacity") == '0') { if ($('.mapListSection').css("opacity") == '0') {
$('.mapListSection').animate({'opacity': '1'}, 1000); $('.mapListSection').animate({'opacity': '1'}, 1000);
@ -41,7 +70,6 @@ $(function() {
$('#totalPages').text(features.pages); $('#totalPages').text(features.pages);
$('#searchField').removeAttr("disabled"); $('#searchField').removeAttr("disabled");
$('#searchField').removeClass("loading"); $('#searchField').removeClass("loading");
// var headerRow = getHeaderRow(); // var headerRow = getHeaderRow();
// console.log(response); // console.log(response);
var currFeatures = jsonLayer.features; var currFeatures = jsonLayer.features;