Skip to content

Event Handling

Events in Client Side JavaScript

In Aliveforms there are several event. Handling these events using $.Handle JavaScript API enable creating Single-Condition-Logic. These are usable in multi-step mode only.

These events are

  • screen_{index}_input_change
  • screen_{index}_on_next_pre
  • screen_{index}_on_next
  • screen_{index}_on_back
  • screen_{index}_on_enter
  • screen_{index}_on_error
  • screen_{index}_timer_expired
  • form_on_submit_pre
  • form_on_submit
  • form_on_submit_error

screen_index_input_change

If using JavaScript API, event screen_index_input_change is triggered when input of that screen index is changed.

screen_index_on_next_pre

If using JavaScript API, screen_index_on_next_pre is triggered when next button is clicked. It is executed before validation.

screen_index_on_next

If using JavaScript API, screen_index_on_next is triggered when next button is clicked. It is executed after validation.

screen_index_on_back

If using JavaScript API, screen_index_on_back is triggered when back button is clicked.

screen_index_on_enter

If using JavaScript API, screen_index_on_enter is triggered when form screen is rendered.

screen_index_on_error

If using JavaScript API, screen_index_on_error is triggered when error notification in form screen is rendered.

screen_index_timer_expired

If using JavaScript API, screen_index_timer_expired is triggered when timer set on screen is expired.

form_on_submit

If using JavaScript API, form_on_submit is triggered when form response is submitted and result is shown.

form_on_submit_pre

If using JavaScript API, form_on_submit_pre is triggered when form submission is being prepared and wait screen is shown.

form_on_submit_error

If using JavaScript API, form_on_submit_error is triggered when there is error in form submission.

Usage

Ideally, event handlers for events can be defined in screen -1 , i.e. boot.

$.Handle('screen_2_input_change', function() {
  console.log('inp', inputs[2]);
});
$.Handle('screen_1_on_next_pre',function() {
    ...
});
$.Handle('screen_1_on_next',function() {
    ...
});
$.Handle('screen_1_on_back',function() {
    ...
});
$.Handle('screen_1_on_enter',function() {
    ...
});
$.Handle('screen_1_on_error',function() {
    ...
});
$.Handle('screen_1_timer_expire',function() {
    ...
});
$.Handle('form_on_submit_pre',function() {
    ...
});
$.Handle('form_on_submit',function() {
    ...
});
$.Handle('form_on_submit_error',function() {
    ...
});

Single Condition Logics

By registering event handler for these events , it is possible to construct Single Condition Logic. That means, whole form can be programmed from single condition by using function of applicable indexes.