[jQuery] Re: empty() is very slow

2009-08-28 Thread Josh Powell
Change the onclick event handler into a jQuery .live() event and you'll be fine for sure. On Aug 26, 1:57 pm, oleOhle wrote: > OK, thanks everybody! I think I understand. > > Actually my second attempt could easily be rewritten to match exactly > what jQuery does. It really boils down to the rem

[jQuery] Re: empty() is very slow

2009-08-26 Thread oleOhle
OK, thanks everybody! I think I understand. Actually my second attempt could easily be rewritten to match exactly what jQuery does. It really boils down to the remove() function, which does some magic to remove data and events related to the contained DOM elements. Since I only have one HTML onCl

[jQuery] Re: empty() is very slow

2009-08-26 Thread MorningZ
"What is jQuery doing to empty an element?" That's so easy to see/find-out for yourself open up the jquery.js file, search for "emtpy" and voila empty: function() { // Remove element nodes and prevent memory leaks jQuery(this).children().remove(); // Remove

[jQuery] Re: empty() is very slow

2009-08-26 Thread Josh Powell
.empty and .html looks in every node that it removes/replaces and checks for and removes event bindings in order to prevent memory leaks. If you know you do not have bound events, first use plain old javascript to set element.innerHTML = ''; and then remove/replace the element using .empty()/.htm

[jQuery] Re: empty() is very slow

2009-08-26 Thread James
I've found something that worked a faster to empty something when I tested it. function replaceHtml(el, html) { var oldEl = typeof el === "string" ? document.getElementById(el) : el; if (oldEl == null) return null; var newEl = oldEl.cloneNode(false); newEl.innerHTM