0

看,这很好用:

class Page extends Spine.Model
 @configure "Page", "name"
 @extend Spine.Model.Ajax

但是这个:

class Page extends Spine.Model
 @configure "Page", "name"
 @extend Spine.Model.Ajax.Methods

 @fetch (params) ->
  index  = @last()?.id or 0
  return false if index is @index
  @index = index

  params or= 
    data: {index: index}
    processData: true

  @ajax().fetch(params)

不工作。当然,它从服务器获取记录,但其他 REST 命令不起作用。我无法更新或删除记录。我必须做什么才能恢复功能?我需要这个 fetch() 的例子,但我也需要更新和删除。

4

1 回答 1

1

如果您只想覆盖该fetch方法,您可以简单地执行此操作

class Page extends Spine.Model
  @configure "Page", "name"
  @extend Spine.Model.Ajax

  @fetch (params) ->
    index = @last()?.id or 0
    return false if index is @index
    @index = index

    params or= 
      data: {index: index}
      processData: true

    super(params)

注意super最后调用默认提取参数的调用

于 2012-08-07T19:36:49.330 回答