What is the least ugly way to force Backbone.sync updates to use POST instead of PUT?

前端 未结 5 1583
走了就别回头了
走了就别回头了 2020-12-05 14:29

Some of my Backbone models should always use POST, instead of POST for create and PUT for update. The server I persist these models to is capable of supporting all other ve

5条回答
  •  生来不讨喜
    2020-12-05 14:54

    add a sync(method, model, [options]) directly to your models you need to override.

    YourModel = Backbone.Model.extend({
      sync: function(method, model, options) {
        //perform the ajax call stuff
      }
    }
    

    Here's some more information: http://documentcloud.github.com/backbone/#Sync

提交回复
热议问题