cancel
Showing results for 
Search instead for 
Did you mean: 

DOM element click the button but do not call press function defined for Button

former_member602416
Participant
0 Kudos

Hi All,

I am working on a project and I have a requirement to capture events user performs on SAP UI5 app and playback same events when required.

I have developed a small UI5 app with few text fields, buttons and links. I am using java script DOM events to capture the events. I save element id and type of command(click, input) in my local Json model. When playback is required I use saved data to perform same events again.

I am successfully able to capture and playback text input fields but when i click button or link in playback it clicks the button but do not call function defined in controller on press event of button.

Can someone help me on this.In below my example during playback, button click works but it does not call controller function back.

Example code -

View file has button defined -

var Submit = new sap.m.Button("Submit",{

text: 'Submit', enabled: true,

press: function(oEvt) { oController.OnPressSubmit(oEvt)

} });

Controller has function defined -

OnPressSubmit: function(oEvt){ //Perform action }

Another .js file injected in index file, capture events like below

document.addEventListener("input", myInputFunction);

function myInputFunction(evt) {

if (event.target.localName.length > 0) {

recordingData.push({

"type": event.target.localName,

"command": event.type,

"name": event.target.id, "value": event.target.value }); }

sendData(recordingData); };

In Playback -

function playDataBack(Data) {

for (var i = 0; i < playbackData.length; i++) {

if (playbackData[i].command == 'input')

document.getElementById(playbackData[i].name).value = playbackData[[i]].value;

if (playbackData[i].command == 'click') {

var targBtn = document.querySelector ("#" + playbackData[i].name);

var clickEvent = document.createEvent ('MouseEvents');

clickEvent.initEvent ('click', true, true);

targBtn.dispatchEvent (clickEvent);

} }; }

0 Kudos

I'm having the same issue trying to achieve a similar thing. Did you manage to come up with a solution?

former_member27
Community Manager
Community Manager
0 Kudos

Hi James,

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time please note that:

You are adding a comment to an old post that is not likely to get an answer.

I suggest starting a new question and following these guidelines:

I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

For example, you can:

- outline what steps you took to find answers (and why they weren't helpful)

- share screenshots of what you've seen/done

- make sure you've applied the appropriate tags

- use a more descriptive subject line

The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html

Regards,

Dedi

Accepted Solutions (0)

Answers (0)