JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
JavaScript
// Backbone model save method with {patch: true} option sends a POST request with ALL the attributes
$(function() {
Backbone.$ = $;
var User = Backbone.Model.extend({
url: "/testUrl",
isNew : function () { return false; },
defaults: {
attrib1: true,
attrib2: 3,
attrib3: "test",
attrib4: {}
}
});
var user = new User();
user.save(
{attrib2: true},
{
patch: true,
error: function(model, xhr, options) {
// the only attribute that actually changed
console.log(model.changed);
// backbone options
console.log(options);
}
}
);
});