reiern70 opened a new issue, #1650:
URL: https://github.com/apache/wicket/issues/1650
An `AjaxFormSubmitBehavior` whose `shouldTriggerJavaScriptSubmitEvent()`
returns `true` (an `AjaxButton` or `AjaxFallbackButton` overriding it) fires a
`submit` event on the form before its Ajax request, so that submit handlers
run. `UploadProgressBar` relies on this to start its bar, and the Ajax upload
example uses it.
On master the precondition fires the event with `dispatchEvent(new
Event('submit', { cancelable: true, bubbles: true }))`. Firefox still submits a
form for a `submit` event fired by a script unless the event is cancelled, so
in Firefox the button sends its Ajax request **and** submits the form the
normal way. The page is reloaded behind the Ajax response: in the upload
example the selected file is gone, the buttons are disabled again and the form
is processed twice. Chrome does not submit a form for such an event, so the
problem only shows in Firefox.
**To reproduce:** open the Ajax upload example (`/ajax/upload`) in Firefox,
select a file and click "Ajax Submit". Besides the Ajax POST to the button's
listener, the browser posts the form to the form's own listener and the page
reloads.
**Affected versions:** master only. The precondition came with the
jQuery-free implementation of the Ajax engine (615af3ee95), which is not
released. Wicket 10.x was checked in Firefox and is not affected: its
precondition triggers the event through jQuery and cancels it in its own
handler, so the form is not submitted. No backport is needed.
**Proposed fix:** a `Wicket.Event.triggerSubmit(form)` function in both
engines (`wicket-ajax-jquery.js` and `wicket-ajax.js`) that fires the event,
tells whether a submit handler cancelled it, and cancels it once it has bubbled
up to the window, so no browser submits the form for it. The precondition calls
that function. A handler cancelling the event still stops the Ajax request.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]