JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//cdn.jsdelivr.net/select2/3.4.8/select2.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/select2/3.4.8/select2.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ractive/1.0.0-build-99/ractive.js"></script>
<main></main>
<script id='template' type='text/ractive'>
<p>selected value: {{selection}}</p>
<select decorator="select2:selection" value="{{selection}}">
{{#options}}
<option value="{{.}}">{{.}}</option>
{{/options}}
</select>
</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
Ractive.decorators.select2 = function ( node, keypath ) {
var ractive = this;
$(node).select2().on( 'change', function () {
debugger;
ractive.set( keypath, this.value );
});
return {
teardown: function () {
$(node).select2( 'destroy' );
}
};
};
var ractive = new Ractive({
el: 'main',
template: '#template',
data: { options: [ 'a', 'b', 'c', 'd', 'e' ] }
});
ractive.observe('selection', function(){
debugger;
});