Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect that last page has loaded? #35

Open
bgmat opened this issue Feb 15, 2019 · 2 comments
Open

Detect that last page has loaded? #35

bgmat opened this issue Feb 15, 2019 · 2 comments

Comments

@bgmat
Copy link

bgmat commented Feb 15, 2019

Hi,

Is there a way to know, in the callback function, that the last page has loaded?

Thanks

@Cam
Copy link
Member

Cam commented May 21, 2019

@bgmat you could extend the getTheHtmlOfTheNextPageWithAnAjaxRequest function to check if the XMLHttpRequest returns something other than the next page pretty easily.

I'll look at adding this to the next version 👍

@BrendanBerkley
Copy link

Good feature request.

In the meantime, I did this:


  const callback = () => {
    const nextPageLink = document.querySelector("[data-paginate-next]");
    const pageCount = nextPageLink.getAttribute("href").split("?page=")[1];

    if (typeof pageCount === "undefined") {
      nextPageLink.classList.add("hide");
    }
  };

  new Ajaxinate({
    method: "click",
    container: "#AjaxinateContainer",
    pagination: "#AjaxinatePagination",
    loadingText: "Loading...",
    callback: callback,
  });

Then you'd want the hide class to have a style of display: none.

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

No branches or pull requests

3 participants