0

Look, this works fine:

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

but this:

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)

not working. Of course, it fetches records from server, but other REST-commands not working. I can't update or delete record. What I have to do to restore functionality? I need this example of fetch(), but I need update and delete too.

none
  • 1,699
  • 2
  • 13
  • 18

1 Answers1

1

If you only wish to override the fetch method you could simply do this

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)

Notice the super call in the end calling the default fetch with your params

Michiel
  • 234
  • 2
  • 12