JSFiddle - React, Tailwind, and code Playground
by toddfx
HTML
<script src="http://cdn.ractivejs.org/edge/ractive.js"></script>
<main></main>
<script id='template' type='text/ractive'>
<button on-click='moveTo:1'>move to section 1</button>
<button on-click='moveTo:2'>move to section 2</button>
<button on-click='moveTo:3'>move to section 3</button>
<div id="section1">
<h1> Section 1 </h1>
<div class='target' data-target='1'></div>
</div>
<div id="section2">
<h1> Section 2 </h1>
<div class='target' data-target='2'></div>
</div>
<div id="section3">
<h1> Section 3 </h1>
<div class='target' data-target='3'></div>
</div>
</script>
<script id='subcomponent' type='text/ractive'>
<p>I'm a subcomponent</p>
</script>
CSS
body {
font-family: 'Helvetica Neue', arial, sans-serif;
font-weight: 200;
color: #353535;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 200;
}
JavaScript
var subcomponents = [];
var ractive = new Ractive({
el: 'main',
template: '#template'
});
var Subcomponent = Ractive.extend({
template: '#subcomponent'
});
var subcomponent = new Subcomponent; //subcomponents.push(new Subcomponent());
ractive.on( 'moveTo', function ( event, target ) {
subcomponent.insert( '.target[data-target="' + target + '"]' );
});