Skip to content

Instantly share code, notes, and snippets.

@tstachl
Created November 12, 2014 00:24
Show Gist options
  • Save tstachl/f1c4760c76f80b743dc0 to your computer and use it in GitHub Desktop.
Save tstachl/f1c4760c76f80b743dc0 to your computer and use it in GitHub Desktop.
Load all cases without pagination on the My Cases page in the desk.com portal by adding this snippet of jquery code. It basically loads the next page of each page that has a next page specified and appends all the cases to the initial page.
(function($) {
function nextPage(url, callback) {
$.get(url, function(data, textStatus, jqXHR) {
var cases = $(data).find('.mycases tbody tr')
, nextUrl = $(data).find('#pagination a.next_page');
callback(cases);
if (nextUrl && nextUrl.attr('href')) nextPage(nextUrl.attr('href'), callback);
}, 'html');
}
var nextUrl = $('#pagination a.next_page');
if (nextUrl && nextUrl.attr('href')) {
nextPage(nextUrl.attr('href'), function(cases) {
$('.mycases tbody').append(cases);
});
$('#pagination').hide();
}
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment