Class XataJax.form
Defined in: xatajax.form.core.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
A class with static utility functions for working with forms.
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
XataJax.form.createForm(method, params, target)
Creates a form with the specified parameters.
|
| <static> |
XataJax.form.findField(startNode, fieldName)
Finds a field by name relative to a starting point.
|
| <static> |
XataJax.form.submitForm(method, The, target)
Creates and submits a form with the specified parameters.
|
Method Detail
<static>
{HTMLElement}
XataJax.form.createForm(method, params, target)
Creates a form with the specified parameters. This can be handy if you
want to submit a form dynamically and don't want to use AJAX.
XataJax.form.createForm('GET', {
'-action': 'my_special_action',
'val1': 'My first value'
'val2'; 'My second value'
});
- Parameters:
- {String} method
- The method. Either 'get' or 'post'
- {Object} params
- The key/value pairs that the form should submit.
- {String} target
- The target of the form.
- Returns:
- {HTMLElement} jQuery object wrapping the form tag.
<static>
{HTMLElement}
XataJax.form.findField(startNode, fieldName)
Finds a field by name relative to a starting point. It will search only within
the startNode's form group (i.e. class xf-form-group).
This method of finding sibling fields is compatible with the grid widget so that it will return the sibling widget of the specified name in the same row as the source widget. However it will also work when the widgets are displayed normally.
Note: This is designed to work with fields in the Xataface edit and new record forms and not just general html forms. It looks for the data-xf-field-fieldname HTML attribute to identify the fields by name. Xataface automatically adds this attribute to all fields on its forms.
//require <xatajax.form.core.js>
var form = XataJax.load('XataJax.form');
var firstNameField = jQuery('#first_name');
var lastNameField = form.findField(firstNameField, 'last_name');
// lastNameField should contain the last name field in the same form
// group as the given first name field.
- Parameters:
- {HTMLElement} startNode
- The starting point of our search (we search for siblings).
- {String} fieldName
- The name of the field we are searching for.
- Returns:
- {HTMLElement} The found field or null if it cannot find it.
<static>
{void}
XataJax.form.submitForm(method, The, target)
Creates and submits a form with the specified parameters.
XataJax.form.submitForm('POST', {
'-action': 'my_special_action',
'val1': 'My first value'
'val2'; 'My second value'
});
- Parameters:
- {String} method
- The method of the form (e.g. get or post)
- {Object} The
- key/value pairs to submit with the form.
- {String} target
- The target of the form.
- Returns:
- {void}