One thing that continues to confuse me about Marionette is how to structure it efficiently.
Let's consider a simple interface for displaying a list of comments and adding a new comment. I am currently structuring this using a CommentApp
as shown below.
I have a couple of questions:
Is this the correct way to structure such an application? I tried following the BBCloneMail Example App where possible, but it doesn't illustrate creating new items in a collection.
Why does the layout.listRegion
return undefined
when calling .show()
on it? Is there a definitive approach to handling triggering and binding to 'layout:rendered'
events with nested layouts?
App.module "CommentApp", (CommentApp, App, B, M, $, _) ->
// code snippet here
The 'comment_layout'
template simply serves as a basic container template:
<h2>Comments</h2>
<section id="comment_list_region"></section>
<section id="new_comment_region"></section>
I use JST
to render it by overriding the rendering function like so:
# Override the marionette renderer to make it use JST.
Backbone.Marionette.Renderer.render = (template, data) ->
// code snippet here