Skip to content

Instantly share code, notes, and snippets.

@aligo
Created June 4, 2012 13:14
Show Gist options
  • Save aligo/2868294 to your computer and use it in GitHub Desktop.
Save aligo/2868294 to your computer and use it in GitHub Desktop.
wait_get =
waitGet: (id, callback) ->
self = this
model = @get(id)
if model?
callback.call(this, model)
else
@on('reset', (->
callback.call(self, self.get(id))
self.off null, null, id
), id)
_.extend Backbone.Collection.prototype, wait_get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment