Using composite representations with a basic puppet and relational

I have been using Marionette for several weeks and have just opened Backbone Relational, so I'm trying to figure out how to integrate the two. Ideally, I would like to use a composite view to display data that is structured in a way where each element has its own element view:

list : { name : 'List 1', items : [ item1 : { name : 'Item 1', id : 1 }, item2 : { ... } item3 : { ... } ] } 

Usually with composite views, you should have a set of models that it will iterate over to render each element. With relational, I just got one model (list), and this model has a collection (elements) inside it. Is it possible to do this using puppet representations, or do I need to use the simple "Highway" view and handle the rendering and iteration myself?

+7
source share
1 answer

This is quite common and easy. In your CompositeView definition, you can specify the collection to use in the initialize method.

 Backbone.Marionette.CompositeView.extend({ // ... initialize: function(){ this.collection = this.model.get("childcollection"); } }); 
+19
source

All Articles