@@ -14,6 +14,18 @@ module('data-confirm', {
1414 text : 'Click me'
1515 } ) ) ;
1616
17+ $ ( '#qunit-fixture' ) . append ( $ ( '<form />' , {
18+ id : 'confirm' ,
19+ action : '/echo' ,
20+ 'data-remote' : 'true'
21+ } ) ) ;
22+
23+ $ ( '#qunit-fixture' ) . append ( $ ( '<input />' , {
24+ type : 'submit' ,
25+ form : 'confirm' ,
26+ 'data-confirm' : 'Are you absolutely sure?'
27+ } ) ) ;
28+
1729 this . windowConfirm = window . confirm ;
1830 } ,
1931 teardown : function ( ) {
@@ -105,6 +117,27 @@ asyncTest('clicking on a button with data-confirm attribute. Confirm No.', 3, fu
105117 } , 50 ) ;
106118} ) ;
107119
120+ asyncTest ( 'clicking on a submit button with form and data-confirm attributes. Confirm No.' , 3 , function ( ) {
121+ var message ;
122+ // auto-decline:
123+ window . confirm = function ( msg ) { message = msg ; return false } ;
124+
125+ $ ( 'input[type=submit][form]' )
126+ . bind ( 'confirm:complete' , function ( e , data ) {
127+ App . assertCallbackInvoked ( 'confirm:complete' ) ;
128+ ok ( data == false , 'confirm:complete passes in confirm answer (false)' ) ;
129+ } )
130+ . bind ( 'ajax:beforeSend' , function ( e , data , status , xhr ) {
131+ App . assertCallbackNotInvoked ( 'ajax:beforeSend' ) ;
132+ } )
133+ . trigger ( 'click' ) ;
134+
135+ setTimeout ( function ( ) {
136+ equal ( message , 'Are you absolutely sure?' ) ;
137+ start ( ) ;
138+ } , 50 ) ;
139+ } ) ;
140+
108141asyncTest ( 'binding to confirm event of a link and returning false' , 1 , function ( ) {
109142 // redefine confirm function so we can make sure it's not called
110143 window . confirm = function ( msg ) {
0 commit comments