BaseModel.js 934 B

1234567891011121314151617181920212223
  1. define([ "require", "utils/Utils", "backbone", "utils/CommonViewFunction" ], function(require, Utils, Backbone, CommonViewFunction) {
  2. "use strict";
  3. var BaseModel = Backbone.Model.extend({
  4. initialize: function() {},
  5. toString: function() {
  6. throw new Error("ERROR: toString() not defined for " + this.modelName);
  7. },
  8. silent_set: function(attrs) {
  9. return this.set(attrs, {
  10. silent: !0
  11. });
  12. }
  13. }, {
  14. nonCrudOperation: function(url, requestMethod, options) {
  15. return options.beforeSend = CommonViewFunction.addRestCsrfCustomHeader, options.data && "object" == typeof options.data && (options.data = JSON.stringify(options.data)),
  16. Backbone.sync.call(this, null, this, _.extend({
  17. url: url,
  18. type: requestMethod
  19. }, options));
  20. }
  21. });
  22. return BaseModel;
  23. });