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

addContent of view is asynchronous with DOM change?

116 Views

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: http://veui5infra.dhcp.wdf.sap.corp:8080/snippix/snippets/23872

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