Created
July 3, 2012 05:58
-
-
Save juliocesar/3037975 to your computer and use it in GitHub Desktop.
Getting headers on Backbone.Collection.prototype.fetch
This file contains 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
# Actually more of an example of how to pick headers value and put them in Backbone collections. | |
class HeadersAwareCollection extends Backbone.Collection | |
parse : (resp, xhr) -> | |
@total = xhr.getResponseHeader('X-Total-Results') | |
super | |
# Alternatively, call `xhr.getAllResponseHeaders()`, parse the text, and add the whole object to | |
# the collection. | |
# Thanks @philoye for pointing out that `parse` is a better fit than `fetch` for this! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment