Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Current »

Form script allows you to perform operations before the form is rendered or to attach data model elements to get notifications. Form script also has some library functions like $Xml depending on the context. Please refer to the side bar for available library functions and scripting reference.

Form script also has the following $Form variable with the following properties:

$Form = {
  element : $('form'),       // jQuery form element
  refresh : function() {}    // method to re-build and render form from the scratch
  readonly : boolean,        // Specifies whether the form is in readonly or in edit mode
  sections : {}              // List of form sections
}


Common Usage Scenarios

Change Form Section States

The form section states normally defined task properties as follows;

image-20240109-113723.png

Relevant form sections can be changed dynamically to control the hidden and disabled state of sections on the form.

In addition to static assignments form section states can be updated with the following form script.

if ($Xml.EvaluateBoolean('SomeCondition')) {
  $Form.sections['MySection'] = 'Hidden';     // set MySection to Hidden state.
}

Section state can be defined as;

State

Description

(Empty)

Default state

Hidden

Hide from user

Disabled

Readonly

Attach Event Handlers.

Attach a model element to existing data . 

$Xml.Bind('Person/Name', function() {
   // executed when Person/Name is changed
});

The above example normally works if the Name element exists in the Person element. But some elements may not exist yet when the form is rendered. For example, Bind method does not work for list items that are not yet created. If you want to attach nodes for future elements you can use $Xml.Live method.

$Xml.Live('List/Item/Amount', function() {
   // executed when List/Item/Amount is changed
});

Use Custom jQuery Plugins

// attach jquery event to form ready event
$Form.element.on('ready', function() {
   // find custom added panel and initialize plugin
   $Form.element.find('.myCustomPanel').myCustomPlugin();
});



  • No labels