There must be a better way !

There must be a better way !


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.