2

I'm trying to render list of records using CompositeView and I'm unable to identify an event which will be fired post rendering of all the child records.

I went through the documentation and found below methods which have not worked yet -

  1. onRenderCollection - after the collection of models has been rendered
  2. onRender - after everything has been rendered
  3. render:collection - tried it just for the heck of it

Below is the current code snippet -

        View.childItem = Backbone.Marionette.ItemView.extend({
            template: childTpl,
            tagName: 'tr'
        });


        View.parentPane = Backbone.Marionette.CompositeView.extend({
            template: parentTpl,
            childView: View.childItem,
            childViewContainer: "#childList",
            events: {

            },
            onAfterRender: function (ev) {
                $('tbody').css('height', '210px')); // trying to control the height dynamically..
            },

        });

2 Answers2

0

I think you are looking for the onRender:

Additionally, after the composite view has been rendered, an onRender method will be called. You can implement this in your view to provide custom code for dealing with the view's el after it has been rendered.

View.parentPane = Backbone.Marionette.CompositeView.extend({
  template: parentTpl,
  childView: View.childTpl,
  childViewContainer: "#childList",
  onRender: function () {
    $('tbody').css('height', '210px')); // trying to control the height dynamically..
  }
});
Tholle
  • 108,070
  • 19
  • 198
  • 189
  • strangely my onRender was firing at the start of the render event and not after it and hence was hoping for a onAfterRender which won't work. – Sachin Hegde Aug 05 '16 at 05:36
0

Try render:collection/onRenderCollection. See "render" event in the Marionette documentation.

David Williamson
  • 387
  • 1
  • 5
  • 18