Skip to content

Instantly share code, notes, and snippets.

@mtheoryx
Created February 5, 2014 17:12
Show Gist options
  • Select an option

  • Save mtheoryx/8828602 to your computer and use it in GitHub Desktop.

Select an option

Save mtheoryx/8828602 to your computer and use it in GitHub Desktop.
JS for conditional pagination
var stringTest = "Showing 1 to 4 of 10 entries";
stringTest = stringTest
.replace('Showing', '')
.replace('to ', '')
.replace('of ', '')
.replace('entries', '')
.replace(" ", "")
.trim();
stringTest = stringTest.split(" ");
var container_end = stringTest[1];
var collection_end = stringTest[2];
console.log(container_end);
console.log(collection_end);
console.log(stringTest);
// If our container_end is less than our collection_end
// Then we need pagination, and we keep it
// If not, just get rid of pagination altogether
// Regardless, we get rid of the info anyway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment