jquery/jquery-mobile — Issue #3424: Feature request: formbeforesubmit, formsubmit, formresponse events
Author: danielcha
Created: 2012-01-12 15:47:42+00:00
State: open

I would like to propose a formbeforesubmit, formsubmit and formresponse events for ajax submitted forms.

formbeforesubmit
This would enable the programmer to add, remove or edit the form data before it is submitted, or do a pre-submit validation of the entered values. Also it makes it possible to prompt an alert like "Are you sure you want to submit the form".

formsubmit
Called when the ajax request has been sent. Possible to display a loading gif or message while waiting for a response from the server. Or redirect the user back to the previous page.

formresponse
Called when JQM receives the server response. At this point the response has to be in the JQM page format to be placed in the DOM. This event would enable us to let the server reply with JSON or any format, and on the client side formresponse will translate the received data into a JQM page or perform other tasks.

Most of these things can be achieved with some hacking, but because I really feel all page events give JQM alot of flexability and power, why not do the same for forms? Comments are welcome