:: libs :: js-as-form :: as-form-events

Library index

Events

DOM events must be triggered on DOM nodes.

The AS.form object triggers many events on document node, on the asForm.fakeForm() node and the various asField.getWrap() nodes.

The best way to register your events is through the AS.addEvent() function, see Dealing with events for details.

Events whose type contains : are CustomEvents, and they can optionally carry data in the event.detail property.

Document events

Field events are triggered on the document DOM node.

To add your own event listener use e.g.:

let myFunction = function(e){ console.log(e.detail.realForm().innerHTML); };
AS.addEvent( document, 'as:formRendered', myFunction );

List of event types:

Type event.detail Triggered on…
as:fieldRendered asField object Field rendering occurred
as:formCreated asForm object New form object was created
as:formDestroy asForm object Form was eliminated
as:formRendered asForm object Form rendering occurred
as:formSubmit Form JS data Form submit is going to happen
as:pluginLoadOver JS data Load is over, plugins in event.detail
as:popupClose JS data Popup was closed and data returned
as:popupOpen asForm object Popup was created

Form events

Form events are triggered on the asForm.fakeForm() DOM node.

To add your own event listener use e.g.:

let myFunction = function(e){ console.log(e.detail); };
let myForm = AS.form.getForm(-1);
AS.addEvent( myForm.fakeForm(), 'as:change', myFunction );

List of event types:

Type event.detail Triggered on…
as:afterReset JS data after reset Form reset occurred
as:beforeReset JS data before reset Form is going to be reset
as:change Form was changed
as:reset Form reset occurred
as:submit Form JS data Form submit is going to happen

Field events

Field events are triggered on the asField.getWrap() DOM node.

To add your own event listener use e.g.:

let myFunction = function(e){ console.log(e.detail); };
let myForm = AS.form.getForm(-1);
let myField = myForm.getField('myFieldName');
AS.addEvent( myField.getWrap(), 'as:afterSetValue', myFunction );

List of event types:

Type event.detail Triggered on…
as:afterSetValue String value Field value change occurred
as:beforeSetValue JS value Field value change is going to occurr
as:change Field was changed
as:enabled Bool enabled status Field was enabled or disabled
as:scrollTo View scrolled to Field
as:setValue Field value change occurred
as:visibility Bool visibility status Field was shown or hidden
as:validated Bool valid status Field validation occurred
as:warning Bool warning status Field warning was shown or hidden