Skip to content

Instantly share code, notes, and snippets.

@infacq
Created January 20, 2014 04:53
Show Gist options
  • Save infacq/8515016 to your computer and use it in GitHub Desktop.
Save infacq/8515016 to your computer and use it in GitHub Desktop.
One way to avoid it, is to collect all rendered elements into one documentFragment, which is basically just a container for DOM elements, and then appending that single container to the DOM tree - triggering only a single page reflow. http://ozkatz.github.io/avoiding-common-backbonejs-pitfalls.html
render: function() {
this.$el.empty();
var container = document.createDocumentFragment();
// render each subview, appending to our root element
_.each(this._views, function(subview) {
container.appendChild(subview.render().el)
});
this.$el.append(container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment