jsdoc.forms¶
File: biweeklybudget/flaskapp/static/js/forms.js
-
handleForm
(container_id, form_id, post_url, dataTableObj, serialize_func)¶ Generic function to handle form submission with server-side validation.
See the Python server-side code for further information.
Arguments: - container_id (string) – The ID of the container element (div) that is the visual parent of the form. On successful submission, this element will be emptied and replaced with a success message.
- form_id (string) – The ID of the form itself.
- post_url (string) – Relative URL to post form data to.
- dataTableObj (Object) – passed on to
handleFormSubmitted()
- serialize_func (Object) – If set (i.e. not
undefined
), this is a function used serialize the form in place ofserializeForm()
. This function will be passed the ID of the form (form_id
) and should return an Object suitable for passing toJSON.stringify()
.
-
handleFormError
(jqXHR, textStatus, errorThrown, container_id, form_id)¶ Handle an error in the HTTP request to submit the form.
-
handleFormSubmitted
(data, container_id, form_id, dataTableObj)¶ Handle the response from the API URL that the form data is POSTed to.
This should either display a success message, or one or more error messages.
Arguments: - data (Object) – response data
- container_id (string) – the ID of the modal container on the page
- form_id (string) – the ID of the form on the page
- dataTableObj (Object) – A reference to the DataTable on the page, that needs to be refreshed. If null, reload the whole page. If a function, call that function. If false, do nothing.
-
handleInlineForm
(container_id, form_id, post_url, dataTableObj)¶ Generic function to handle form submission with server-side validation of an inline (non-modal) form.
See the Python server-side code for further information.
Arguments: - container_id (string) – The ID of the container element (div) that is the visual parent of the form. On successful submission, this element will be emptied and replaced with a success message.
- form_id (string) – The ID of the form itself.
- post_url (string) – Relative URL to post form data to.
- dataTableObj (Object) – passed on to
handleFormSubmitted()
-
handleInlineFormError
(jqXHR, textStatus, errorThrown, container_id, form_id)¶ Handle an error in the HTTP request to submit the inline (non-modal) form.
-
handleInlineFormSubmitted
(data, container_id, form_id, dataTableObj)¶ Handle the response from the API URL that the form data is POSTed to, for an inline (non-modal) form.
This should either display a success message, or one or more error messages.
Arguments: - data (Object) – response data
- container_id (string) – the ID of the modal container on the page
- form_id (string) – the ID of the form on the page
- dataTableObj (Object) – A reference to the DataTable on the page, that needs to be refreshed. If null, reload the whole page. If a function, call that function. If false, do nothing.
-
isFunction
(functionToCheck)¶ Return True if
functionToCheck
is a function, False otherwise.From: http://stackoverflow.com/a/7356528/211734
Arguments: - functionToCheck (Object) – The object to test.
-
serializeForm
(form_id)¶ Given the ID of a form, return an Object (hash/dict) of all data from it, to POST to the server.
Arguments: - form_id (string) – The ID of the form itself.