luis-almeida/jPages

Page link

PeterPan73 opened this issue · 4 comments

How can I make as an exemplary'm second page and the addres link in url to be (example) www.site.com/scrollbrowse.html?page=2.
Thanks

I have the same issue, I need to have the pages reachable by a URL, beacause I have anchors for every item, and they are reachable only for the first page. How can I achieve this?

Any help?

For the anchors I resolved by disabling jPages if there is an anchor in the URL, but I know it's not the answer for your question.

I needed to do something similar to this, and came up with the following setup:

/** turn the query string into a javascript object */
function getQueryParams() {
  var queryString = location.search.substr(1).split('&');
  var params = {};

  queryString.forEach(function(param) {
    var p = param.split('=');
    params[p[0]] = p[1];
  });

  return params;
}

/** updates the location bar with the current page */
function updatePageParam(pageNum) {
  var baseUrl = location.pathname.replace(/\/$/, '');
  baseUrl += pageNum > 1 ? '/?page=' + pageNum : '';
  history.replaceState(null, null, baseUrl);
}

/** Paginates the list of categories using jPages plugin */
function paginate() {
  var params = getQueryParams();

  $('.pagination').jPages({
    containerID: 'pages',
    startPage: params.page,
    callback: function(pages) {
      updatePageParam(pages.current);
    }
  });
}

Hope this helps, even though it's quite a few months after you asked the question!