Skip to content
Advertisement

How to use `oEvent` when loading fragment asynchronously?

I’m able to used oEvent when using this code:

JavaScript

However, I’m trying to change it using Fragment.load but I’m not able to get the oEvent from the function. Any idea?

JavaScript

Advertisement

Answer

As explained in the linked answer above, the oEvent parameters are completely reset after the event handler (onPressDialog) is executed. I.e. after the fragment is fetched asynchronously, the oEvent object won’t contain the same references / parameter values anymore. Try storing the target reference in a closure variable before creating the fragment, and then use the variable when the promise is finally resolved.

Given <Dialog id="myDialog"> in the fragment definition:

Since UI5 1.93

Using the API oController.loadFragment

JavaScript

Since UI5 1.58

Using the API Fragment.load

JavaScript
Advertisement