$.voForm() extends jQuery

Source: theme/lib/js/cmn-form.js

This tool was originally created to work with the VO form builder. This form builder creates a database version that can accept data. We have not kept it up to date and the editor's functionality in VO4 is not complete. The script $.voForm works on the resulting form and manual-built forms as well.

Onload it will look for tags with the class of .voForm. It the rel attribute has a number then it will look at the form as a VO Form generated form. If not, then it uses the voFormCustom method.

Usage

Simply add the class of voForm to any form or div tag and it will harness the containging inputs to communicate with the server via ajax and handle responses accordingly.

Settings via tag attributes

Attribute Values
rel Custom ajax URL. If number, then it communicates with form id at the vo-form endpoint
data-no-scroll type: bool
default: false
true will not scroll back to the top of the form
data-no-reset type: bool
default: false
true will not reset form after getting success response.
data-reroute-after-message type: string
If set then it will reroute to the URL set after the success message has displayed for seven seconds.
data-verify-action type: bool | string
default: false
If string is set then it will popup a dialog with the message of this string with a verification action.
data-verify-btnokay type: string
default: "Ok"
When clicked the ajax action will proceed.
data-verify-btncancel type: string
default: "Cancel"
When clicked the ajax action will be canceled.
data-button-value  
data-placeholder  
data-reroute  
data-redirect-url  
data-success-message Overrides the ajax success data.message response.
data-hide-form-after-submit  
data-dom-replace  
data-html  

Settings via JavaScript

These are data settings that are set on the selected voForm selector object.

ajaxSuccess

Parameter: response -- the ajax response data

$('.voForm').data('ajaxSuccess',function(resp){
	if( ! resp.error_message ){
		// If no error_message then it is a successful response
	}
});

promiseChain

Use case: When you don't want the form to wait until other processes are finished. The submit event of this form will not run until preset array of promises are done.

This uses the promiseChain utility method found in the sabramedia-*.js library.

Example: How to add a promise to the chain

$('.voForm').data('promiseChain').push(function(event) {

	// Do something that could be an asynchronous event i.e., 
	// a jQuery ajax call which returns promise object.
	
	// return 'promise object goes here';
});

Settings on inputs

Submit button

Ajax Response Controls

Schedule
a Demo