@@ -24,6 +24,10 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
24
24
attrs . newEmail
25
25
26
26
const validateCaptchaIfEnabled = function ( callback ) {
27
+ scope . $applyAsync ( ( ) => {
28
+ scope [ attrs . name ] . inflight = true
29
+ } )
30
+
27
31
if ( attrs . captchaActionName ) {
28
32
validateCaptchaV3 ( attrs . captchaActionName )
29
33
}
@@ -34,7 +38,7 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
34
38
}
35
39
}
36
40
37
- const submitRequest = function ( grecaptchaResponse ) {
41
+ const _submitRequest = function ( grecaptchaResponse ) {
38
42
const formData = { }
39
43
for ( const data of Array . from ( element . serializeArray ( ) ) ) {
40
44
formData [ data . name ] = data . value
@@ -46,7 +50,6 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
46
50
47
51
// clear the response object which may be referenced downstream
48
52
Object . keys ( response ) . forEach ( field => delete response [ field ] )
49
- scope [ attrs . name ] . inflight = true
50
53
51
54
// for asyncForm prevent automatic redirect to /login if
52
55
// authentication fails, we will handle it ourselves
@@ -143,7 +146,7 @@ App.directive('asyncForm', ($http, validateCaptcha, validateCaptchaV3) => ({
143
146
}
144
147
145
148
const submit = ( ) =>
146
- validateCaptchaIfEnabled ( response => submitRequest ( response ) )
149
+ validateCaptchaIfEnabled ( response => _submitRequest ( response ) )
147
150
148
151
const _httpRequestFn = ( method = 'post' ) => {
149
152
const $HTTP_FNS = {
0 commit comments