Posted on

Events in UI5 in 3 Simple Steps

Event means action . The most common types of event are Click, Tap, Drag, Press, Change, Focus, KeyPress  .

Let us refer to our previous project which we have done earlier here .

So, at the time of pressing the submit button, we will execute a particular function so that an event will get fired.

Here we will use the onChange event handler function.

Step1:-  Let us go to the API reference URL and search for sap.m.input and again search for the liveChange event from Here .

Now , let us go to our demo.view.js page and create a function over there with the name as liveChange :-


var oSimpleInput = new sap.m.Input({
liveChange:[oController.liveChange,oController],
placeholder:"Enter Name"
})

Step2:- Let us create a function in our demo.controller.js with the toast message creation function which will be displayed on top of the page the string that is typed by the user :-


liveChange: function(oEvt){

var sValue = oEvt.getParameter('value');
sap.m.MessageToast.show(sValue);
},

Step3:- So here comes the output below and the change event is fired when the user writes any text on the text box:

Output

 

That’s all for now . Stay tuned for more 🙂