JSFiddle - React, Tailwind, and code Playground

by b_m_h

HTML

<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone.js"></script>
  <div id= "post">
    
  </div>
  
<script type="text/template" id="template">
<input type="button" id="button" value="load" />
</script>

JavaScript

var PostModel = Backbone.Model.extend({
    urlRoot : '/echo/json',
    defaults:{
        name: '',
        content: ''
    }

});

var PostView = Backbone.View.extend({
  events: {
    'click #button' : 'loadModel'
  },
  
  initialize: function() {
    this.render();
  },
  
  loadModel :function(){
        this.model.fetch();
  },
  
  render: function() {
    var template = _.template($('#template').html());
    this.$el.html(template());
  }
});

var post = new PostModel({
    id: 1
});
var view = new PostView({
  el: $('#post'),
  model: post
});