I am using a pagination plugin called pajinate, i need to provide a Show All option, so I am passing in the index of my ajax call to the “item_per_page”. Everything works great, but I need to add 1 to the index, so i get the full results.
When i set the “item_per_page” to just “i”, it works, when i set it to “i + 1”, it does not. Doesn’t make sense to me:
$.ajax({
url: "search-by-department-621650415.json",
cache: true,
dataType : 'json',
success : function(results) {
var employeeData = [];
var totalNum;
var startNum = 9;
$.each(results.data, function(i, item){
employeeData.push({
departmentName: item.departnemtName,
firstname: item.firstName,
lastname: item.lastName,
phonework: item.workPhone
});
totalNum = i;
//totalNum = i + 1; breaks when i do this!!
});
$('#employee-name-results').tmpl(employeeData).appendTo('#name-results-container');
Pagination(startNum);
$("a.showall").click(function() {
Pagination(totalNum);
});
}
});
function Pagination(itemsPerPage) {
$('#paging_container-1').pajinate({
items_per_page : itemsPerPage,
num_page_links_to_display : 8,
abort_on_small_lists: true,
nav_label_prev : '<img src="images/icons/icon_prev.png" />',
nav_label_next : '<img src="images/icons/icon_next.png" />'
});
console.log(itemsPerPage);
}
found the if statement in the Plugin:
if (options.abort_on_small_lists && options.items_per_page >= $items.size()) return $page_container;
Needs to be:
if (options.abort_on_small_lists && options.items_per_page > $items.size()) return $page_container;