@@ -244,7 +244,7 @@ function pjax(options) {
244
244
245
245
var allowed = fire ( 'pjax:error' , [ xhr , textStatus , errorThrown , options ] )
246
246
if ( options . type == 'GET' && textStatus !== 'abort' && allowed ) {
247
- locationReplace ( container . url )
247
+ window . location . assign ( container . url )
248
248
}
249
249
}
250
250
@@ -269,16 +269,20 @@ function pjax(options) {
269
269
270
270
// If there is a layout version mismatch, hard load the new url
271
271
if ( currentVersion && latestVersion && currentVersion !== latestVersion ) {
272
- locationReplace ( container . url )
272
+ window . location . assign ( container . url )
273
273
return
274
274
}
275
275
276
276
// If the new response is missing a body, hard load the page
277
277
if ( ! container . contents ) {
278
- locationReplace ( container . url )
278
+ window . location . assign ( container . url )
279
279
return
280
280
}
281
281
282
+ if ( options . push ) {
283
+ cachePush ( pjax . state . id , cloneContents ( context ) )
284
+ }
285
+
282
286
pjax . state = {
283
287
id : options . id || uniqueId ( ) ,
284
288
url : container . url ,
@@ -288,7 +292,9 @@ function pjax(options) {
288
292
timeout : options . timeout
289
293
}
290
294
291
- if ( options . push || options . replace ) {
295
+ if ( options . push ) {
296
+ window . history . pushState ( pjax . state , container . title , container . url )
297
+ } else if ( options . replace ) {
292
298
window . history . replaceState ( pjax . state , container . title , container . url )
293
299
}
294
300
@@ -355,13 +361,6 @@ function pjax(options) {
355
361
var xhr = pjax . xhr = $ . ajax ( options )
356
362
357
363
if ( xhr . readyState > 0 ) {
358
- if ( options . push && ! options . replace ) {
359
- // Cache current container element before replacing it
360
- cachePush ( pjax . state . id , cloneContents ( context ) )
361
-
362
- window . history . pushState ( null , "" , options . requestUrl )
363
- }
364
-
365
364
fire ( 'pjax:start' , [ xhr , options ] )
366
365
fire ( 'pjax:send' , [ xhr , options ] )
367
366
}
0 commit comments