advanced.js 857 Bytes
Newer Older
1
define(["backbone"], function(Backbone) {
cahrens committed
2

3
var Advanced = Backbone.Model.extend({
4

cahrens committed
5
    defaults: {
cahrens committed
6
        // the properties are whatever the user types in (in addition to whatever comes originally from the server)
cahrens committed
7
    },
cahrens committed
8 9

    validate: function (attrs) {
10
        // Keys can no longer be edited. We are currently not validating values.
11
    },
David Baumgold committed
12

13 14 15 16 17 18 19 20 21
    save : function (attrs, options) {
        // wraps the save call w/ the deletion of the removed keys after we know the saved ones worked
        options = options ? _.clone(options) : {};
        // add saveSuccess to the success
        var success = options.success;
        options.success = function(model, resp, options) {
          if (success) success(model, resp, options);
        };
        Backbone.Model.prototype.save.call(this, attrs, options);
22 23
    }
});
24 25 26

return Advanced;
}); // end define()