简体   繁体   中英

SAPUI5 Execute Code After Page has Fully Rendered

I am injecting a Javascript-File via a Chrome-Extension on a webpage that uses SAPUI5. I want to get the model in the binding context of some UI5-Input elements and in order to do so, I need to get to the inputs via document.getElementsByTagName . (or is there another way?)

This only works if they are already rendered. Unfortunately the ready or load events fire too early, when not everything is rendered yet.

Is there a way for me to know when the inputs have rendered?

Edit: I do not have access to the source code of the page, everything I do has to be in the injected script.

To make sure everything is renedered before firing your events, sapui5 has the function onAfterRendering .

All logic written in that function will only be executed after the control is rendered.

When a rerender of the control is rendered, the onAfterRendering is triggered again.

In the end I did it like this:

I already had event listeners attached to click and key events. Every time the handler is called, I check if document.getElementsByTagName('input') returns the inputs I need.

If yes eg the rendering of the inputs is complete, I set a boolean that the page is loaded completely and execute my code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM