I want to insert some html asynchronously into the page, and then execute some javascript codes correlated with the inserted DOM.
This kind of endeavour always fail because DOM rendering in the browser takes much more time than the next javascript codes to execute.
I have met with such problem before and have asked a question, but nobody answered. It's here: https://stackoverflow.com/questions/31935005/whats-going-on-with-dom-after-orientationchange-event
So, can I get a promise or attach some callback function?
Codes here:
var bubble = function bubble(type,content){
var myScroll, temp = document.createElement('div');
temp.innerHTML=content;
temp.className=type==='time'?'time':'bubble '+type;
document.getElementsByClassName('dialogue')[0].appendChild(temp);
if(type==='reply')myScroll = new IScroll('.dlg-wrapper', { mouseWheel: true });
};