JSFiddle - React, Tailwind, and code Playground
by Eric Howe
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"></script>
JavaScript
var M = Backbone.Model.extend({
initialize: function() {
this.listenTo(this, 'change', this.m);
},
m: function() {
if('a' in this.changed || 'b' in this.changed)
console.log('a or b changed');
}
});
var m = new M;
console.log('setting a and b');
m.set({ a: 'a', b: 'b' });
console.log('setting a');
m.set({ a: 'aa' });
console.log('setting b');
m.set({ b: 'bb' });
console.log('setting c');
m.set({ c: 'c' });