@@ -99,6 +99,24 @@ asyncTest('form input[type=submit][data-disable-with] disables', 6, function(){
99
99
} , 30 ) ;
100
100
} ) ;
101
101
102
+ test ( 'form input[type=submit][data-disable-with] re-enables when `pageshow` event is triggered' , function ( ) {
103
+ var form = $ ( 'form:not([data-remote])' ) , input = form . find ( 'input[type=submit]' ) ;
104
+
105
+ App . checkEnabledState ( input , 'Submit' ) ;
106
+
107
+ // Emulate the disabled state without submitting the form at all, what is the
108
+ // state after going back on firefox after submitting a form.
109
+ //
110
+ // See https://github.com/rails/jquery-ujs/issues/357
111
+ $ . rails . disableFormElements ( form ) ;
112
+
113
+ App . checkDisabledState ( input , 'submitting ...' ) ;
114
+
115
+ $ ( window ) . trigger ( 'pageshow' ) ;
116
+
117
+ App . checkEnabledState ( input , 'Submit' ) ;
118
+ } ) ;
119
+
102
120
asyncTest ( 'form[data-remote] input[type=submit][data-disable-with] is replaced in ajax callback' , 2 , function ( ) {
103
121
var form = $ ( 'form:not([data-remote])' ) . attr ( 'data-remote' , 'true' ) , origFormContents = form . html ( ) ;
104
122
@@ -173,6 +191,18 @@ asyncTest('a[data-disable-with] disables', 4, function() {
173
191
start ( ) ;
174
192
} ) ;
175
193
194
+ test ( 'a[data-disable-with] re-enables when `pageshow` event is triggered' , function ( ) {
195
+ var link = $ ( 'a[data-disable-with]' ) ;
196
+
197
+ App . checkEnabledState ( link , 'Click me' ) ;
198
+
199
+ link . trigger ( 'click' ) ;
200
+ App . checkDisabledState ( link , 'clicking...' ) ;
201
+
202
+ $ ( window ) . trigger ( 'pageshow' ) ;
203
+ App . checkEnabledState ( link , 'Click me' ) ;
204
+ } ) ;
205
+
176
206
asyncTest ( 'a[data-remote][data-disable-with] disables and re-enables' , 6 , function ( ) {
177
207
var link = $ ( 'a[data-disable-with]' ) . attr ( 'data-remote' , true ) ;
178
208
0 commit comments