I'm trying to create a filterable portfolio using a jquery slider, using easySlider and code I have adapted from various tutorials. The portfolio items are rendered as an unordered list, and shown or hidden based on their css class. I've managed to get this part working properly, but I can't work out what to do about the slider. It no longer shows the hidden items, but continues to display empty slides where they used to be.
Any ideas how I can somehow clear the slider function, and then re-call it after each time the slider is filtered.
Here is my code so far:
$(document).ready(function(){
$("#slider").easySlider({
auto: true,
continuous: true,
numeric: true,
controlsBefore: '',
pause: 3000
});
$("#filter-portfolio a").click(function() {
$('#filter-portfolio .filteredby').removeClass('filteredby');
$(this).addClass('filteredby');
var filterVal = $(this).text().toLowerCase().replace(' ','-');
if(filterVal == 'both') {
$('#slider li.hidden').removeClass('hidden');
}
else {
$('#slider li').each(function() {
if(!$(this).hasClass(filterVal)) {
$(this).addClass('hidden');
$(this).remove();
} else {
$(this).removeClass('hidden');
$('#slider li').appendTo('#slider ul');
}
});
var count = $("#slider ul li:not('.hidden')").length -1;
$('#controls li:not(li:lt(' + count + '))').remove();
}
return false;
});
});
Any help is much appreciated, as I'm tearing my hair out here! Let me know if I've missed out any necessary information.
EDIT: As requested, here is an example of the page in action.
Thanks, Sam