diff --git a/jquery.pjax.js b/jquery.pjax.js index 0a9cb1e1..f2d37026 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -252,17 +252,15 @@ function pjax(options) { locationReplace(container.url) return } - - pjax.state = { - id: options.id || uniqueId(), - url: container.url, - title: container.title, - container: context.selector, - fragment: options.fragment, - timeout: options.timeout - } - if (options.push || options.replace) { + pjax.state = { + id: options.id || uniqueId(), + url: container.url, + title: container.title, + container: context.selector, + fragment: options.fragment, + timeout: options.timeout + } window.history.replaceState(pjax.state, container.title, container.url) } @@ -318,7 +316,7 @@ function pjax(options) { // using the container and options of the link we're loading for the // back button to the initial page. This ensures good back button // behavior. - if (!pjax.state) { + if ((options.push || options.replace) && !pjax.state) { pjax.state = { id: uniqueId(), url: window.location.href, @@ -439,6 +437,7 @@ function onPjaxPopstate(event) { url: state.url, container: container, push: false, + replace: true, fragment: state.fragment, timeout: state.timeout, scrollTo: false