JSFiddle - React, Tailwind, and code Playground

by Cody Lindley

HTML

<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/jquery-2.0.2.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/lodash.underscore.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/backbone.js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

var contact= new Backbone.Model();

var ContactView = Backbone.View.extend({
    initialize:function(){
        this.listenTo(contact,'change',this.render); //listen to change event on model
    },
    render:function(){
        console.log('data changed, re-render');
    }
});

new ContactView();

contact.set({ //this triggers change event
    firstName:'john',lastName:'Doe',phone:'111-111-1111'
});

contact.unset('phone'); //this triggers change event