que-es
asked on
jQuery - Pagination of Visible Results?
Hello,
I'm trying to paginate only visible results, after they have been filtered (made hidden or visible) by other jQuery controls. The plugins I have tried seem to ignore the filtering controls, by not updating the pagination after a filter has been applied or removed. How would I go about this? Printing a count of visible/total for the user would be a nice touch.
An unpaginated sample is available here. Many thanks to mplungjan, as this is the result of our Filter Results by More Than 2 Intersections discussion.
Any help is much appreciated.
I'm trying to paginate only visible results, after they have been filtered (made hidden or visible) by other jQuery controls. The plugins I have tried seem to ignore the filtering controls, by not updating the pagination after a filter has been applied or removed. How would I go about this? Printing a count of visible/total for the user would be a nice touch.
An unpaginated sample is available here. Many thanks to mplungjan, as this is the result of our Filter Results by More Than 2 Intersections discussion.
Any help is much appreciated.
ASKER
I've taken several passes at altering the above code to achieve paginated display of visible elements, but so far no dice. Any further insight/input would be appreciated.
Yeah, sorry I did not get it done. I'll push the "Request Attention" for you
ASKER
It's OK, & thank you.
ASKER
Hi,
The request for help was sent on 3/31, though nothing further has happened. Does anyone have a suggestion to resolve this question?
Thanks.
The request for help was sent on 3/31, though nothing further has happened. Does anyone have a suggestion to resolve this question?
Thanks.
I'll take one more look tomorrow
ASKER
Thanks very much!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is fantastic, thank you. I have been going through it to understand your process & how it works. Will integrate it into the larger solution tomorrow and report back. Sending you that email.
I've requested that this question be deleted for the following reason:
The question has either no comments or not enough useful information to be called an "answer".
The question has either no comments or not enough useful information to be called an "answer".
ASKER
The conversation started by the poster's solution was very informative, and I learned from it.
Thanks - Me too. This is one reason I answer questions here for free :)
Here is the code from the jsFiddle
Here is the code from the jsFiddle
/* Filtering and pagination
(c) 2012 Michel Plungjan - javascripts(a)plungjan.name */
var max = 5,cnt=0,sel,selLength;
$(document).ready(function() {
$('input:checkbox').attr('checked', 'checked');
$(".chk").click(function() {
$(".chk:checked").each(function() {
$("."+this.id).show();
});
$(".chk:not(:checked)").each(function() {
$("."+this.id).hide();
});
init();
});
init();
});
function init() {
cnt=0;
sel = $("li:visible");
selLength = sel.length;
go(0);
}
function nav() {
var nav = $("#nav").empty();
if(selLength==0) {
nav.append("Selection did not result in any courses");
return;
}
nav.append((cnt==0)?'<span class="disabled"><</span>':'<a href="#" onclick="return go(-1)"><b><</b></a>');
var end = cnt+max;
if (end > selLength) end = selLength;
nav.append(" "+(cnt+1)+"-"+end+" of "+selLength+" ");
nav.append((end>=selLength)?'<span class="disabled">></span>':'<a href="#" onclick="return go(1)"><b>></b></a>');
}
function go(dir) {
if (dir<0) cnt-=max;
if (dir==1) cnt+=max;
sel.hide();
for (var i=cnt,n=0;i<selLength && n<max;i++,n++) {
sel.eq(i).show();
}
nav();
}
Open in new window