How to make my javascript function wait for a html element to render -
there single page application in angularjs. has nested tabs. in inner tab there button on event gets fired.i need trigger click event of button present on inner tab button gets rendered after both tabs rendered. best way wait until tabs render , button available.
i tried using 'while loop'(i.e keep looping until id button undefined) , $timeout(set timeout 2-3 seconds) service both have consequences when there delay in tab render.
please suggest if there exists better approach.
you can jquery: $(document).ready(callbackfn);
or native js:
document.addeventlistener('readystatechange', function onreadystatechange() { if (document.readystate !== "complete") return; callbackfn(); }, false);
Comments
Post a Comment