File tree 2 files changed +25
-2
lines changed
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -281,14 +281,14 @@ function pjax(options) {
281
281
state : pjax . state ,
282
282
previousState : previousState
283
283
} )
284
- context . html ( container . contents )
284
+ options . context . html ( container . contents )
285
285
286
286
// FF bug: Won't autofocus fields that are inserted via JS.
287
287
// This behavior is incorrect. So if theres no current focus, autofocus
288
288
// the last field.
289
289
//
290
290
// http://www.w3.org/html/wg/drafts/html/master/forms.html
291
- var autofocusEl = context . find ( 'input[autofocus], textarea[autofocus]' ) . last ( ) [ 0 ]
291
+ var autofocusEl = options . context . find ( 'input[autofocus], textarea[autofocus]' ) . last ( ) [ 0 ]
292
292
if ( autofocusEl && document . activeElement !== autofocusEl ) {
293
293
autofocusEl . focus ( ) ;
294
294
}
Original file line number Diff line number Diff line change @@ -563,6 +563,29 @@ if ($.support.pjax) {
563
563
} )
564
564
} )
565
565
566
+ asyncTest ( "change context node in pjax:beforeReplace event handler" , function ( ) {
567
+ var frame = this . frame ,
568
+ targetContent = 'foo' ,
569
+ changedTarget = frame . $ ( 'ul > li:first' )
570
+ changedTargetOriginalContent = changedTarget . text ( )
571
+
572
+ frame . $ ( "#main" )
573
+ . text ( targetContent )
574
+ . on ( "pjax:beforeReplace" , function ( event , contents , options ) {
575
+ options . context = changedTarget ;
576
+ } )
577
+ frame . $ ( "#main" ) . on ( "pjax:success" , function ( event ) {
578
+ notEqual ( changedTarget . text ( ) , changedTargetOriginalContent )
579
+ equal ( $ ( event . target ) . text ( ) , targetContent )
580
+ start ( )
581
+ } )
582
+
583
+ frame . $ . pjax ( {
584
+ url : "hello.html" ,
585
+ container : "#main"
586
+ } )
587
+ } )
588
+
566
589
asyncTest ( "triggers pjax:success event from container" , function ( ) {
567
590
var frame = this . frame
568
591
You can’t perform that action at this time.
0 commit comments