News for hackers. Stuff that matters.
Re:Rendering Backbone Collections with DocumentFragment by Aqueous on Monday April 15, 2013 @10:36AM (#5551671)
You could render off-screen in a fragment or couldn't you just make an element using the view's "make" convenience function, append all objects to that, and then append that to the view? Does this require the same reflows?
Re:Rendering Backbone Collections with DocumentFragment by trebor on Monday April 15, 2013 @10:58AM (#5551793)
Technically, even if you render outside the visible area you still incur reflows/repaints. A fragment isn't rendered at all, but lets you build the entire collection as HTML once then do just one reflow/repaint to add the whole fragment to the DOM.
Re:Rendering Backbone Collections with DocumentFragment by wwarnerandrew on Monday April 15, 2013 @12:25PM (#5552354)
What about using something like jquery detach? Then you could, when rendering, detach the element, render all the content, subviews, and re-append it. That shouldn't trigger reflows, right?
Re:Rendering Backbone Collections with DocumentFragment by trebor on Monday April 15, 2013 @01:52PM (#5552944)
Correct. So far as I know, the way jQuery detach works is to remove it from the DOM and then return the individual element. The element could act as a fragment, because it can contain children, and then be reappended to the DOM.
Re:Rendering Backbone Collections with DocumentFragment by dmethvin on Monday April 15, 2013 @02:01PM (#5553019)
Right, and even better than a document fragment since fragments have both unusual semantics and API limitations that normal elements do not (e.g., no getElementsByTagName or getElementById).
Re:Rendering Backbone Collections with DocumentFragment by elving on Monday April 15, 2013 @12:17PM (#5552314)
This --^

Great answer!