Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.49 KB

ajax.rst

File metadata and controls

39 lines (29 loc) · 1.49 KB

Using Ajax Forms

To create a form object that uses AJAX, you can do the following.

from deform import Form
myform = Form(schema, buttons=('submit',), use_ajax=True)

creating_a_form indicates how to create a Form object based on a schema and some buttons. Creating an AJAX form uses the same constructor as creating a non-AJAX form. The only difference between the example provided in the creating_a_form section and the example above of creating an AJAX form is the additional use_ajax=True argument passed to the Form constructor.

If use_ajax is passed as True to the constructor of a deform.Form object, the form page is rendered in such a way that when a submit button is pressed, the page is not reloaded. Instead the form is posted, and the result of the post replaces the form element's DOM node.

Examples of using the AJAX facilities in Deform are showcased on the https://deformdemo.pylonsproject.org demonstration website:

Note

As with widgets, you must ensure the required JavaScript files are included for the AJAX functionality to work. See widget_requirements for a way to detect which JavaScript libraries are required for a particular form rendering.