When editing large forms it can be frustrating if the form were to be accidentally closed by clicking on the background before submitting the changes. To address this, you can use the events provided by Editor to check if a user has closed the form without saving changes, and ask them to confirm if this is what they want to do.
This is done by using the onOpen and onPreClose events, in combination with the get method. get, when passed no parameters, will give you the values for all fields in the form, as an object. As such, when the form is opened (onOpen) the values of the form in that opening state can easily be saved for comparison later. Then when the form is closed, the onPreClose event is fired, and allows you to cancel the closing action by returning false from the event handler's function. Using get again, with a simple loop, we can check to see if any values have changed and ask them if they really do want to close the form without saving their changes.
| Browser | Rendering engine | Platform(s) | Engine version | CSS grade |
|---|---|---|---|---|
| Browser | Rendering engine | Platform(s) | Engine version | CSS grade |
The Javascript below is what is used on this page for the example shown.
The HTML shown below shows the TABLE that is used in this example.
The code below is that HTML that is used to drive the server-side section of this exampe.
The HTML shown below includes the Javascript and CSS files that are required for the Editor operation on this page. You can use this as a template for your own pages, but if you move the files you might need to update the paths.
Editor submits and retrieves information by Ajax requests. The two blocks below show the data that Editor submits and receives, to and from the server. This is updated live as you interact with Editor so you can see what is submitted.
The following shows the data that has been submitted to the server when a request is made to add, edit or delete data from the table.
// No data yet submitted
The following shows the data that has been returned by the server in response to the data submitted on the left and is then acted upon.
// No data yet received
DataTables can request information to display from the server when the page first loads. The block below shows the response from the server.