Display lightbox on Infinite Scroll – Cordial Knowledge Base

How can we help?

Overview

This article shows you how to get your lightbox to display on Infinite Scroll.

If your URL does not change

You would need to call our function any time that they want to signal a "new page view". This will tell our code to re-process itself, and display any eligible boxes.

window.PRIMER_API.LIGHTBOX.onInfiniteScrollPageChanged(url, send_pv_event, update_pv_based_vars, use_master_rules, re_calc_ab_tests);

Since the URL doesn't change, we want that to be an empty string (which tells us to just use the current URL). The other parameters are boolean values (true/false). We recommend the following setup:

window.PRIMER_API.LIGHTBOX.onInfiniteScrollPageChanged("", true, true, false, false);

If your URL changes

Same as above, just use instead:

var new_url = window.location.href;
window.PRIMER_API.LIGHTBOX.onPageUrlChanged(new_url, true, true, false, false);

Troubleshooting

If your function is being called before the primer webforms script loads:

var retryPrimerPageChangeInterval = setInterval(function() {
  if (window.PRIMER_API.LIGHTBOX.isPrimerReady()) {
    window.PRIMER_API.LIGHTBOX.onInfiniteScrollPageChanged("", true, true, false, false);
    clearInterval(retryPrimerPageChangeInterval);
  }
}, 500);