Skip to content

Instantly share code, notes, and snippets.

@hrtovey
Created April 16, 2020 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrtovey/f82e9f84f713b87af93f2bc054c865bf to your computer and use it in GitHub Desktop.
Save hrtovey/f82e9f84f713b87af93f2bc054c865bf to your computer and use it in GitHub Desktop.
Wrap blog code in code that listens for Ajax page change.
<script>
document.addEventListener('DOMContentLoaded', init);
window.addEventListener('mercury:load', init);
function init(){
// Blog Pagination Links Code goes here
document.querySelectorAll('.BlogList-pagination-link-label').forEach(function(paginationLink) {
if (paginationLink.textContent == "Newer") {
paginationLink.textContent = "More"; // Customize "Newer" text here
} else {
paginationLink.textContent = "More"; // Customize "Older" text here
}
})
}
</script>
@pietew
Copy link

pietew commented Apr 27, 2020

Hello Heather,

This code snippet is gold when having Ajax enabled and helped me solve my problem after hours of trial and error 🥇

I tried it on a default Brine template to change the 'shopping cart' label in the checkout page and that's working. You can see this on https://chihuahua-tomato-t9b4.squarespace.com/cart (pw: covid19)

However, when I'm using the exact same code on the Hester template, which is basically the 7.1 version of Brine, it's not working . You can see this on https://maisonblanchegeel.squarespace.com/cart (pw: covid19)

Both templates have the same HTML structure and are using the same CSS classes so I'm very confused why there's a difference. Got any insight on that?

Thanks in advance for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment