Exclude model properties when syncing (Backbone.js)

后端 未结 11 1430
甜味超标
甜味超标 2020-12-07 14:26

Is there a way to exclude certain property from my model when I sync?

For example, I keep in my model information about some view state. Let\'s say I have a picker m

11条回答
  •  天涯浪人
    2020-12-07 14:53

    To set only desired values, use HTTP PATCH insead of HTTP POST. On the backbone side, just add a patch attribute to the save method:

    entity.save(data,{patch:true})
    

    Using save with this attribute, only fields passed as data are sent to the server.

提交回复
热议问题