Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save elegantcoder/3392343 to your computer and use it in GitHub Desktop.
Backbone Example Code
fCollection.on 'reset', (collection, opts) ->
# contents of opts
# {
# error: function (model, resp) {}
# parse: true
# success: function (resp, status, xhr) {}
# }
Backbone.Model.extend {
sync: (method, model, options) ->
options.data =
'vmap.id':@get 'vmapId'
'node-name':@get 'nodeName'
'nodeLocation':@get 'nodeLocation'
'nodeToLocation':@get 'nodeToLocation'
options.headers =
token: @get 'token'
switch method
when 'read' then @_read(method, model, options)
when 'create' then @_create(method, model, options)
when 'update' then @_update(method, model, options)
when 'delete' then @_delete(method, model, options)
_read: (method, model, options) ->
Backbone.sync method, model, options
_create: (method, model, options) ->
Backbone.sync method, model, options
_update: (method, model, options) ->
Backbone.sync method, model, options
_delete: (method, model, options) ->
Backbone.sync method, model, options
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment