theironcook / Backbone.ModelBinder

Simple, flexible and powerful Model-View binding for Backbone.
1.42k stars 159 forks source link

Rendering a large collection using CollectionBinder can tie up the browsing context #224

Open platinumazure opened 9 years ago

platinumazure commented 9 years ago

Rendering a large collection can tie up the browsing context and generate long-running script errors.

It's pretty obvious that consumers with large collections should also consider partitioning/paginating their collections to make for an acceptable user experience. However, for consumers that are okay with rendering things in batches, it would be a good idea for CollectionBinder to support some sort of renderBatchSize option (or similar) and render in chunks of that size, calling setTimeout to return control back to the browser temporarily in between. If that option is not specified, all items would render synchronously. Ideally, this logic would activate both on initial bind calls and every time a collection add occurs with more than renderBatchSize models being added.

I'll work on a pull request along these lines in the next couple of days, but if anyone wants to have a go before I do, feel free.