Skip to Content
Former Member
Aug 21, 2015 at 10:27 AM

addContent of view is asynchronous with DOM change?


Hi experts,

I've just encountered a problem with sap.ui.jsview. Here's the thing: when I add some content into the view using "addContent" method, I was expecting that I can get the DOM element of the newly added content immediately. But I found it doesn't work. I can only get the DOM element in a setTimeout function.

Here is the example:

As you can see I am trying to get the dom node of the newly added text control using jquery. But I can't get it unless I put my logic into setTimeout. Also I found that removeContent has the same problem. UI5 will remove the DOM asynchronously.

I am wondering is this a by-designed behavior? And if so, is there any better way for me to access the dom other than putting all code into setTimeout, which may make my code more complex and unreadable?

Thank you for the help!

Best Regard,

Luke Lu