Im struggling to build a proper project filter with jquery isotope. I only want to get the id’s of previous and next projects if they are not hidden by the ‘isotope-hidden’ class. How can I do this?
// Get the id's of previous and next projects
if ( $prev.length !== 0 && $next.length !== 0 ) {
prev_item_id = $prev.find('.project-link').attr( "data-post_id" );
next_item_id = $next.find('.project-link').attr( "data-post_id" );
}
else if ( $prev.length !== 0 ) {
prev_item_id = $prev.find('.project-link').attr( "data-post_id" );
}
else if ( $next.length !== 0 ) {
next_item_id = $next.find('.project-link').attr( "data-post_id" );
}
the problem is I need to put the logic in here somewhere. But I can’t work out how to adapt this to exclude projects hidden by the isotope-hidden class. Is it something like this?
var post_id = $( this ).attr( "data-post_id" );
current_post_id = post_id;
var nonce = $( this ).attr( "data-nonce" );
var $allitems = $('.project-link').not('isotope-hidden');
var $prev = $allitems.[data-post_id="' + post_id + '"]' .parent().parent().prev('.portfolio-item');
var $next = $allitems.[data-post_id="' + post_id + '"]' .parent().parent().next('.portfolio-item');
Any help much appreciated, Thanks
Try the following:
References:
:not(): http://api.jquery.com/not-selector/.data(): http://api.jquery.com/jQuery.data/