Answer the question
In order to leave comments, you need to log in
Backbone/Marionette how to layout/embed templates correctly?
As I understand it, the views in both cases, when created based on a template, after being inserted into the document, are wrapped in an empty DIV. Marionette renders the resulting view into the region that it finds by the selector, and if you use the collection list, then you get a mess
<div id="#region"> -- селектор региона для марионет
<div> -- обертка поверх шаблона вида
<div id="#view-list"> -- содержимое шаблона для вида
<div> -- обертка для каждого элемента списка
<div class="list-item">текст</div>
</div>
<div> -- обертка для каждого элемента списка
<div class="list-item">текст</div>
</div>
...
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Views (views) have their own container. Div is a tag or another, you decide, for this there is a `tagName` property, which by default is exactly equal to `div`. It will also be useful to mention the `className` property, thanks to which you can set the value of the `class` attribute for your view. Use these two properties. If you have some kind of root container in your template, then it is this container that you need to describe with these properties.
A region in the DOM tree is just a container where you can output something.
PS: if you give an example, I will try to fix it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question