Created
August 19, 2012 05:45
-
-
Save elegantcoder/3392343 to your computer and use it in GitHub Desktop.
Backbone Example Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fCollection.on 'reset', (collection, opts) -> | |
# contents of opts | |
# { | |
# error: function (model, resp) {} | |
# parse: true | |
# success: function (resp, status, xhr) {} | |
# } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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