Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 464
Nikhil Agrawal Avatar asked Jan 30 '15 12:01

Nikhil Agrawal


1 Answers

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.

like image 144
joews Avatar answered Nov 12 '22 08:11

joews