I find it faster to first generate a string with all of the html in
it, and then as a last step create the DOM Elements with the $();

example:

var outer = '<div>';
$.each(hash, function() {
  outer += this.ui.render();
});
outer += '</div>';

$(container).append(outer);

That last line might need to be $(container).append($(outer)); but I
don't think so...

On Feb 9, 8:20 am, weepy <jonah...@gmail.com> wrote:
> I'm dynamically inserted a large number of elements into a page.
>
> I want it to be nice and speedy, so I wanted to insert them all at
> once to avoid multiple reflows. The only way I could figure this out
> was  :
>
>     var outer = $("<div>")
>     for(var i in hash) {
>       outer.append( hash[i].ui.render() )
>     }
>     $(container).append( outer.html() )
>
> This works - though perhaps a little cumbersome. However I found that
> the background image that I was setting on the 'render' call was
> getting munged. Essentially the append call removes the single quotes
> around the the url
>
> i.e. background: url('xxxx') => background: url(xxx)
>
> Now this is fine until we try to append this back in - in which case
> it doesn't work.
>
> I was able to reinsert the quotes with the following regex - and if I
> do this it works ok.
>
> var w = h.replace(/url\(([a-zA-Z0-9\/\. ]*)\)/g, function(a,b)
> { return "url('" + b + "')" }  )
>
> Should jQuery reinsert the quotes in the html upon calling .html ? I'm
> not sure if it's a bug or what.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to