Form script allows to perform operations before form is rendered or attach data model elements to get notifications. Form script also have some library functions like $Xml depending on context. Please refer to side bar for available library functions.
Form script also have following $Form variable with following properties;
Code Block |
---|
$Form = {
element : $('form'), // jQuery form element
refresh : function() {} // method to re-build and render form from scratch
readonly : boolean, // Specifies the form is in readonly or edit mode
} |
Common Usage Scenarios
Attach Event Handlers.
Attach to existing a data model element.
Code Block |
---|
$Xml.Bind('Person/Name', function() {
// executed when Person/Name is changed
)); |
Above example is normally works if Name element exists in Person element. But some elements may not exist yet when form rendered. For example Bind method does not work for list items that not yet created. If you want to attach nodes for future elements you can use $Xml.Live method.
Code Block |
---|
$Xml.Live('List/Item/Amount', function() {
// executed when List/Item/Amount is changed
)); |
Use Custom jQuery Plugins
Code Block |
---|
// attach jquery event to form ready event
$Form.element.on('ready', function() {
// find custom added panel and initialize plugin
$Form.element.find('.myCustomPanel').myCustomPlugin();
}); |