Created
December 15, 2012 19:31
-
-
Save h2rd/4298452 to your computer and use it in GitHub Desktop.
Backbone fetch with parameters
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
| MessageList = Backbone.Collection.extend({ | |
| initialize: function(models, options) { | |
| options = options || {}; | |
| this.offset = options.offset || 0; | |
| this.limit = options.limit || 30; | |
| this.sortBy = options.sortBy || 'by_desc'; | |
| }, | |
| url: function() { | |
| return '/messages?' + | |
| 'offset=' + encodeURIComponent(this.offset) + '&' + | |
| 'limit=' + encodeURIComponent(this.limit) + '&' + | |
| 'sort_by=' + encodeURIComponent(this.sortBy); | |
| }, | |
| parse: function(response) { | |
| // Parse models | |
| // Parse offset, limit, sort by, etc | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment