JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/documentcloud/underscore/master/underscore-min.js"></script>
<script src="https://raw.github.com/documentcloud/backbone/77c12aca8fd0db4fb9ca1a8fffe7688971f23bdb/backbone.js"></script>
<div id="modelfields">
<input id="Description" type="text" value="">
<input id="MoreData" type="text" value="">
<input class="save" type="submit" value="save" />
</div>
<script type="text/template" id="template">
<div id="modelfields">
<input id="Description" type="text" value="">
<input id="MoreData" type="text" value="">
<input class="save" type="submit" value="save" />
</div>
</script>
JavaScript
$(function () {
window.MyModel = Backbone.Model.extend({
urlRoot: '/api/m',
});
window.MView = Backbone.View.extend({
template: _.template($('#template').html()),
el: $('#modelfields'),
initialize: function () { this.model.bind('change', this.render, this); },
events: {
"click .save": function () { this.model.save(); }
},
render: function () {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
});
window.MyMView = new MView({model: new MyModel});
});