Form

Usage

  1. <form id="ff" method="post">  
  2.     ...  
  3. </form>  

To make the form become ajax submit form

  1. $('#ff').form({  
  2.     url:...,  
  3.     onSubmit: function(){  
  4.         // do some check  
  5.         // return false to prevent submit;  
  6.     },  
  7.     success:function(data){  
  8.         alert(data)  
  9.     }  
  10. });  
  11. // submit the form  
  12. $('#ff').submit();  

To do a submit action

  1. // call 'submit' method of form plugin to submit the form  
  2. $('#ff').form('submit', {  
  3.     url:...,  
  4.     onSubmit: function(){  
  5.         // do some check  
  6.         // return false to prevent submit;  
  7.     },  
  8.     success:function(data){  
  9.         alert(data)  
  10.     }  
  11. });  

Properties

Name Type Description Default
url string The form action URL to submit null

Events

Name Parameters Description
onSubmit none Fires before submit, return false to prevent submit action.
success data Fires when the form is submitted successfuly.
onBeforeLoad param Fires before a request is made to load data. Return false to cancel this action.
onLoadSuccess data Fires when the form data is loaded.
onLoadError none Fires when some errors occur while loading form data.

Methods

Name Parameter Description
submit options Do the submit action, the options parameter is a object which contains following properties:
url: the action URL
onSubmit: callback function before submit
success: callback function after submit successfuly
load data Load records to fill the form.
The data parameter can be a string or a object type, when string acts as a remote URL, otherwise acts as a local record
clear none Clear the form data
validate none Do the form fields validation, return true when all fields is valid. The method is used with the validatebox plugin.