Adding Custom Listeners to Panel Events

View panels can have custom event handlers that are automatically called when a specific user interface event occurs. There are three event types currently supported:


The custom event handlers are attached to the form panel as follows:

<panel type="form" id="wr_form"
    afterRefresh="wr_form_afterRefresh"
    beforeSave="wr_form_beforeSave"
    beforeDelete="wr_form_beforeDelete">

File: \views\dashboards\staff\ab-dashboard-staff-request.axvw

When the event handlers are called, the Form object is passed as a parameter:

function wr_form_beforeSave(form){

    var fieldValues = form.getFieldValues();

    ...

}

File: \views\dashboards\staff\ab-dashboard-staff-request.js

The beforeSave and beforeDelete event handlers can perform custom form data validation. If the form data is not valid, they can:

function wr_form_beforeSave(form){
    ...
    if (getInputValue('wr.rm_id') == '') {
        form.addInvalidField(
            'wr.rm_id',
            getMessage('error_rm_id'));
        return false;
    }
}

File: \views\dashboards\staff\ab-dashboard-staff-request.js

The Ab.form.Form.addInvalidField() can be called for more than one field – the form will highlight all indicated fields.

The event handler can return true or no value at all to allow the operation.

: