@@ -165,7 +165,7 @@ export default function (Alpine: TAlpine) {
165
165
*/
166
166
const form = Alpine . reactive ( createForm ( ) ) as Data & Form < Data >
167
167
168
- syncWithDom ( el , resolveMethod ( method ) , resolveUrl ( url ) , form )
168
+ syncWithDom ( Alpine , el , resolveMethod ( method ) , resolveUrl ( url ) , form )
169
169
170
170
return form
171
171
} )
@@ -174,15 +174,15 @@ export default function (Alpine: TAlpine) {
174
174
/**
175
175
* Sync the DOM form with the Precognitive form.
176
176
*/
177
- const syncWithDom = < Data extends Record < string , unknown > > ( el : Node , method : RequestMethod , url : string , form : Form < Data > ) : void => {
177
+ const syncWithDom = < Data extends Record < string , unknown > > ( Alpine : TAlpine , el : Node , method : RequestMethod , url : string , form : Form < Data > ) : void => {
178
178
if ( ! ( el instanceof Element && el . nodeName === 'FORM' ) ) {
179
179
return
180
180
}
181
181
182
182
syncSyntheticMethodInput ( el , method )
183
183
syncMethodAttribute ( el , method )
184
184
syncActionAttribute ( el , url )
185
- addProcessingListener ( el , form )
185
+ addProcessingListener ( Alpine , el , form )
186
186
}
187
187
188
188
/**
@@ -231,4 +231,6 @@ const syncSyntheticMethodInput = (el: Element, method: RequestMethod) => {
231
231
/**
232
232
* Add processing listener.
233
233
*/
234
- const addProcessingListener = < Data extends Record < string , unknown > > ( el : Element , form : Form < Data > ) => el . addEventListener ( 'submit' , ( ) => ( form . processing = true ) )
234
+ const addProcessingListener = < Data extends Record < string , unknown > > ( Alpine : TAlpine , el : Element , form : Form < Data > ) => el . addEventListener ( 'submit' , ( ) => {
235
+ Alpine . nextTick ( ( ) => form . processing = true )
236
+ } )
0 commit comments