Skip to content

Commit

Permalink
Fixed non-persistence of cache option after backward navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
nkovacs authored and SilverFire committed Nov 23, 2015
1 parent 18a9183 commit 1cbc33d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ yii-pjax Change Log
2.0.6 Under development
-----------------
- Bug #15: Fixed duplication of `_pjax` GET variable (Alex-Code)
- Bug #21: Fixed non-persistence of `cache` option after backward navigation (nkovacs)
- Bug #23: Fixed loading of scripts in pjax containers (nkovacs, silverfire)
- Enh #25: Blur the focused element if it's inside Pjax container (GeorgeGardiner)
- New: Added `skipOuterContainers` option (silverfire)
Expand Down
31 changes: 16 additions & 15 deletions jquery.pjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ function pjax(options) {
title: container.title,
container: context.selector,
fragment: options.fragment,
timeout: options.timeout
timeout: options.timeout,
cache: options.cache
}

if (options.history && (options.push || options.replace)) {
Expand Down Expand Up @@ -370,7 +371,8 @@ function pjax(options) {
title: document.title,
container: context.selector,
fragment: options.fragment,
timeout: options.timeout
timeout: options.timeout,
cache: options.cache
}
window.history.replaceState(pjax.state, document.title)
}
Expand Down Expand Up @@ -481,7 +483,18 @@ function onPjaxPopstate(event) {
if (container.length) {
var contents = cacheMapping[state.id]

if (previousState) {
var options = {
id: state.id,
url: state.url,
container: container,
push: false,
fragment: state.fragment,
timeout: state.timeout,
cache: state.cache,
scrollTo: false
}

if (previousState && options.cache) {
// Cache current container before replacement and inform the
// cache which direction the history shifted.
cachePop(direction, previousState.id, cloneContents(container))
Expand All @@ -493,15 +506,6 @@ function onPjaxPopstate(event) {
})
container.trigger(popstateEvent)

var options = {
id: state.id,
url: state.url,
container: container,
push: false,
fragment: state.fragment,
timeout: state.timeout,
scrollTo: false
}

if (contents) {
container.trigger('pjax:start', [null, options])
Expand Down Expand Up @@ -884,9 +888,6 @@ function cachePush(id, value) {
//
// Returns nothing.
function cachePop(direction, id, value) {
if(!pjax.options.cache) {
return;
}
var pushStack, popStack
cacheMapping[id] = value

Expand Down

0 comments on commit 1cbc33d

Please sign in to comment.