JSFiddle - React, Tailwind, and code Playground
CoffeeScript
paragraphView = new Thorax.View
events:
'click p': ->
$('body').append 'child clicked<br>'
template: Handlebars.compile """
<p>I'm inside another view, I'll be treated
as my own distinct view.</p>
"""
view = new Thorax.View
name: 'embed-example'
events:
'click p': ->
$('body').append 'parent clicked<br>'
paragraphOne: paragraphView
paragraphThree: $("<p>I'm inside a DOM element
that was created with $ and will be treated
as part of the view.</p>")
template: Handlebars.compile """
<h3>A Tale of Three Paragraphs</h3>
{{view paragraphOne}}
{{template "paragraph-two"}}
{{element paragraphThree}}
<hr>
"""
Thorax.templates['paragraph-two'] = Handlebars.compile """
<p>I'll be embedded directly as a part of the
template and be treated as part of the view.</p>
"""
view.appendTo 'body'