Permalink
Browse files

properly bind the ajax callback

  • Loading branch information...
1 parent 84c7855 commit a626c43481d7805f4e86943467f797f47e52f490 @collin committed Apr 11, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/alpha_simprini/core/model/rest.coffee
@@ -34,18 +34,18 @@ AS.Model.REST = AS.Module.extend ({delegate, include, def, defs}) ->
unless model = AS.All.byId[id]
model = @new()
callback ?= model.didLoad
- @readOne id, callback
+ @readOne id, _.bind(callback, model)
return model
def didLoad: (data) ->
@loadData(data)
- defs readOne: (id, callback=@loadData) ->
+ defs readOne: (id, callback) ->
$.ajax
url: @resourceURL(id)
dataType: 'json'
- success: _.bind(callback, this)
+ success: callback
error: =>
console.error "readone error"
console.error(this, arguments)

0 comments on commit a626c43

Please sign in to comment.