Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suspend layout during DOM interaction

Tags:

javascript

In Javascript I'm clearing out the contents of a DIV and then re-populating it, is there any way to suspend layout of these elements or lock the UI until I've finished slashing away at the HTML? I don't want any messages popping up, I just don't want to see the flicker as the items are removed/added.

like image 348
Mantorok Avatar asked Mar 02 '10 13:03

Mantorok


1 Answers

You could build the new element’s content in a DocumentFragment before inserting it into the actual document:

var fragment = document.createDocumentFragment();
// build node in fragment

var div = /* … */; // DIV that should be replaced
div.parentNode.replaceChild(fragment, div);
like image 191
Gumbo Avatar answered Sep 27 '22 16:09

Gumbo