I am using jquery.paginate plugin to paginate some div elements on the page. But I have a filter that only shows the elements associated with the filter. But I need to run the paginate plugin after the filter has been applied.
I run the filter inside click() when a filter menu link is click, but I cannot access the paginate plugin from within it.
I get an error saying $(...).paginate() is not a function.
I can access the paginate function outside the click() function. See code below at the bottom:
I run the filter inside click() when a filter menu link is click, but I cannot access the paginate plugin from within it.
I get an error saying $(...).paginate() is not a function.
I can access the paginate function outside the click() function. See code below at the bottom:
Code:
$(this).click(function(){
$(this).closest('.w-dyn-list').find('.active-filter').each(function(){
$(this).removeClass('active-filter');
});
var str = $(this).text();
if (str.toLowerCase().indexOf("all") != -1 || str.toLowerCase().indexOf("clear") != -1)
{
var default_heading = $(this).closest("nav").prev().data('heading');
$(this).closest("nav").prev().find(".menutitle").text(jsUcfirst(default_heading));
} else {
$(this).addClass('active-filter');
$(this).closest("nav").prev().find(".menutitle").text(str);
}
var whichFilter;
if($(this).closest('.w-layout-grid').hasClass('adsfilter')){
whichFilter = 'adwrapper';
}else{
whichFilter = 'sitewrapper';
}
console.log(whichFilter);
$('.' + whichFilter).each(function(){
var itm_tags = [];
$(this).find('.tag').each(function(){
itm_tags.push($(this).text().toLowerCase());
});
var allFilters = getAllFilters(whichFilter);
console.log(allFilters);
if(allFilters.length < 1){
showAllItems();
console.log("show all items - error");
}
else
{
if(arrayContainsArray(itm_tags,allFilters) == true){
$(this).closest(".w-dyn-item").fadeIn();
}else{
$(this).closest(".w-dyn-item").hide();
}
}
});
// pagination after filter has been applied.
$('#pagination-list').paginate({
perPage: 9,
scope: $('div'),
});
});// end click(function(){})