JSFiddle - React, Tailwind, and code Playground
JavaScript
var Person = Backbone.Model.extend({
initialize: function () {
},
defaults: {
name: "underfined",
age:"underfined"
}
});
var People = Backbone.Collection.extend({
initialize: function() {
this.bind('add', this.onModelAdded, this);
this.bind('remove', this.onModelRemoved, this);
},
model: Person,
onModelAdded: function(model, collection, options) {
console.log("added, options:", options);
},
onModelRemoved: function (model, collection, options) {
console.log("removeed, options:", options);
},
});
//var person = new Person({ name: "joe1" });
var people = new People();
people.add([{name: "joe1" }, { name: "joe2" }, { name: "joe3" }, { name: "joe4" }, { name: "joe5" }]);
people.remove(people.at(2));
console.log(people.toJSON());