Events Component
  • 13 Feb 2023
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Events Component

  • Dark
    Light
  • PDF

Article Summary

Events are functions that occur due to a particular trigger. These events result in a chain of actions that occur when pages are switched. Multiple events can be triggered using separate event blocks for each component. 

Some of the events in the App Behavior section are: blur, change, focus, select, submit, reset, key-down, key-press, key-up, mouse-over, mouse-up, mouse-down, mouse-move, mouse-out, click, double click, load, error, unload, and resize.

Bind Event:

This block is used to call an event based on the nature of the element and function block. This can be done using a particular trigger from the components in the App designer or a response from the page itself. The nature of the trigger is chosen from the dropdown list inside the block.

InputOutputBlock LayoutGenerated Code


Choose Event Type from the drop-down list

Element Objects - input-1

Function - input-2


Create events for the element object using the function for the chosen event.


 
__er.addEventListener("onclick", "", );

Remove Event

This block is used to remove an existing event from the element object. This can be done using a particular trigger from the components in the App designer or a response from the page itself. The nature of the trigger is chosen from the dropdown list inside the block.

InputOutputBlock LayoutGenerated Code

Choose Event Type from the drop-down list

Element Objects - input-1

Function - input-2



Removes the event from the element object using the function based on the event type.


 
 __er.unbindEvent("onclick", "", );

Trigger Event

This block is used to trigger a particular event. The nature of the trigger is selected from the dropdown list. 

InputOutputBlock LayoutGenerated Code

Choose Event Type from the drop-down list

Element Object - input-1


Trigger the element object event based on the event type


 __er.triggerEvent("onclick", "");

Stop Event

This block is used to stop the further execution of a particular event.

InputOutputBlock LayoutGenerated Code

Event variable

Stop the eventStopEvents
__er.stopEventPropagation("");

Component Event Handler

Each component when dragged and dropped inside a page displays a particular logic in the behavior tab. An event is triggered for each component with their actions that can be performed on them. Events can be triggered for a single component or for an entire page itself. 
InputOutputBlock LayoutGenerated Code
Choose component name from dropdown list-1 to set behavior
(It indicates Component ID)
Choose event from dropdown list-2
(It indicates the list of events for the component)

This creates an event listener for the Component using component Id.

Note

When there is no component selected, the page component is taken by default.



 

function er_3eff8d47_6dd5_4f07_92d0_fd3d291010bd_onPageShow(e,obj,index){

}

Invoke BOS

This block is used to call a BOS service in a page. Only those BOS'es linked to that page are listed in the dropdown list. The block also allows users to write a callback for invoking service blocks. Based on the response from the BOS, the success or failure code blocks are executed.

InputOutputBlock LayoutGenerated Code

By default the invoke service block should have an empty selected. 


It should allow users to select a new service.


The selected BOS is invoked.

The blocks will have success and failure callbacks.




EdgeReady.invokeService(“serviceId”,function(){

//onSuccessStatement

},function(){

//onFailureStatements

}); 

Note
The Invoke BOS makes an asynchronous call to the server, the onSucess and onFailure callback events are executed based on the response.

Enable Loader

This block is used to display a loading spinner on the app screen. If required, the developer can program the loader to hide once the service is completed.

InputOutputBlock LayoutGenerated Code
True - Turns on the loading spinner
False - Turns off the loading spinner
A loading spinner is displayed on the App screen.EnableLoader
function er_1656919493_click(e,obj,index){
   __er.enableLoader('True');

}

Play Audio

This block allows users to play an audio. For example, to play a beep sound for an error message.

InputOutputBlock LayoutGenerated Code

.mp3 file
Note
The audio file must be uploaded in Library > Assets, and assigned to the required project.



play audio
PlayAudio
async function er_1668063187_click(e,obj,index){
   __er.playAudio("");

}


Was this article helpful?

ESC

Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses