@@ -7,11 +7,11 @@ module('call-remote-callbacks', {
7
7
} ) ) ;
8
8
} ,
9
9
teardown : function ( ) {
10
- $ ( document ) . undelegate ( ' form[data-remote]' , 'ajax:beforeSend ') ;
11
- $ ( document ) . undelegate ( ' form[data-remote]' , 'ajax:before ') ;
12
- $ ( document ) . undelegate ( ' form[data-remote]' , 'ajax:send ') ;
13
- $ ( document ) . undelegate ( ' form[data-remote]' , 'ajax:complete ') ;
14
- $ ( document ) . undelegate ( ' form[data-remote]' , 'ajax:success ') ;
10
+ $ ( document ) . off ( 'ajax:beforeSend' , ' form[data-remote]') ;
11
+ $ ( document ) . off ( 'ajax:before' , ' form[data-remote]') ;
12
+ $ ( document ) . off ( 'ajax:send' , ' form[data-remote]') ;
13
+ $ ( document ) . off ( 'ajax:complete' , ' form[data-remote]') ;
14
+ $ ( document ) . off ( 'ajax:success' , ' form[data-remote]') ;
15
15
$ ( document ) . off ( 'ajaxStop' ) ;
16
16
$ ( document ) . off ( 'iframe:loading' ) ;
17
17
}
@@ -371,7 +371,7 @@ function skipIt() {
371
371
}
372
372
373
373
asyncTest ( '"ajax:beforeSend" can be observed and stopped with event delegation' , 1 , function ( ) {
374
- $ ( document ) . delegate ( ' form[data-remote]' , 'ajax:beforeSend ', function ( ) {
374
+ $ ( document ) . on ( 'ajax:beforeSend' , ' form[data-remote]', function ( ) {
375
375
ok ( true , 'ajax:beforeSend observed with event delegation' ) ;
376
376
return false ;
377
377
} ) ;
@@ -429,18 +429,18 @@ if(window.phantom !== undefined) {
429
429
}
430
430
431
431
// IF THIS TEST IS FAILING, TRY INCREASING THE TIMEOUT AT THE BOTTOM TO > 100
432
- asyncTest ( 'binding to ajax callbacks via .delegate () triggers handlers properly' , 4 , function ( ) {
432
+ asyncTest ( 'binding to ajax callbacks via .on () triggers handlers properly' , 4 , function ( ) {
433
433
$ ( document )
434
- . delegate ( ' form[data-remote]' , 'ajax:beforeSend ', function ( ) {
434
+ . on ( 'ajax:beforeSend' , ' form[data-remote]', function ( ) {
435
435
ok ( true , 'ajax:beforeSend handler is triggered' ) ;
436
436
} )
437
- . delegate ( ' form[data-remote]' , 'ajax:send ', function ( ) {
437
+ . on ( 'ajax:send' , ' form[data-remote]', function ( ) {
438
438
ok ( true , 'ajax:send handler is triggered' ) ;
439
439
} )
440
- . delegate ( ' form[data-remote]' , 'ajax:complete ', function ( ) {
440
+ . on ( 'ajax:complete' , ' form[data-remote]', function ( ) {
441
441
ok ( true , 'ajax:complete handler is triggered' ) ;
442
442
} )
443
- . delegate ( ' form[data-remote]' , 'ajax:success ', function ( ) {
443
+ . on ( 'ajax:success' , ' form[data-remote]', function ( ) {
444
444
ok ( true , 'ajax:success handler is triggered' ) ;
445
445
} ) ;
446
446
$ ( 'form[data-remote]' ) . trigger ( 'submit' ) ;
@@ -452,7 +452,7 @@ asyncTest('binding to ajax callbacks via .delegate() triggers handlers properly'
452
452
453
453
asyncTest ( 'binding to ajax:send event to call jquery methods on ajax object' , 2 , function ( ) {
454
454
$ ( 'form[data-remote]' )
455
- . on ( 'ajax:send' , function ( e , xhr ) {
455
+ . bind ( 'ajax:send' , function ( e , xhr ) {
456
456
ok ( true , 'event should fire' ) ;
457
457
equal ( typeof ( xhr . abort ) , 'function' , 'event should pass jqXHR object' ) ;
458
458
xhr . abort ( ) ;
0 commit comments