How to get child views from Backbone Marionette's composite view?
Asked Answered
C

1

10

I am working on an application based on Backbone and Marionette. I am using composite view to show an table now I want to update multiple child view's together So I want their object and model. So to access them

I read this method. I tried them on composite view object but none of the method is working and throwing the error message

CheckInOutCollectionView.findByIndex is not a function

How can I access the child view object?

Capper answered 30/1, 2015 at 12:15 Comment(0)
A
13

If you know the index of the child view:

var child = collectionView.children.findByIndex(0)

If you want to find the child view for a particular model:

var child = collectionView.children.findByModel(model)

This works because CollectionView.prototype.children is a Babysitter ChildViewContainer instance.

This works for CompositeView instances as well because CompositeView extends CollectionView.

Amor answered 30/1, 2015 at 16:15 Comment(2)
I am using version 1.1.0, this functions are available from 2.0 onwards.Capper
Sir do you know how to use findbycustomIndexer().Capper

© 2022 - 2024 — McMap. All rights reserved.