marionettejs/backbone.marionette — pull request #537 by psikocrisis (2013-03-25 09:32:53+00:00)
Title: onCollectionShow trigger

Hi guys,

This is probably the smallest pull request in history :) I'm going to explain why I couldn't solve my problem without this event.

I have a Grid with many records (100,000 for example) and I'm using a jQuery plugin called *DataTables* (http://www.datatables.net/usage/). As you can see in the "Prerequisites" section the plugin requires the table to be already loaded in the DOM in order to work. So here comes the problem. This is my code:

```javascript
var GridController = {
//...
showGrid: function () {
records = new Records();
records.fetch(); // N seconds to load...
gridView = new GridView({
collection: records
});

//emptyView is showed here until
//the collection will be loaded
this.layout.content.show(gridView);
}
}

var GridView = Marionette.CompositeView.extend({
//...
emptyView: LoadingView,
itemView: GridItemView,

onCollectionShow: function () {
// table is fully loaded
this.$('#my-table').dataTable();
}

});
```

I think it's a minor change that doesn't affect the code and can be useful to more people. What do you think?

Thanks!