diff --git a/jquery.pjax.js b/jquery.pjax.js index 9b11ce47..cefb04af 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -248,16 +248,15 @@ function pjax(options) { 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) } @@ -309,7 +308,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 (!pjax.state && (options.push || options.replace)) { pjax.state = { id: uniqueId(), url: window.location.href,