简体   繁体   中英

Using Spine.Model.Ajax, how to handle extra properties in the responsed JSON when model updated

For example:

class User extends Spine.Controller
  @configure 'User', 'name'
  @extend Spine.Model.Ajax
  @url: '/save'

user = new User(name: 'test')
user.save()

User.bind 'update', (item) ->
  console.log(item.flag) # undefined

say '/save' response {flag: 0} because of some database error, when Ajax finished, Spine trigger the update event and update the user model, but there is no flag property extended to user when updated. So, how can I handle this situation when I need to response some extra data that is a little different from model?

在更仔细地阅读了文档之后,我找到了答案:请参阅http://spinejs.com/docs/ajax [自定义序列化]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM