Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created February 9, 2012 01:49
Show Gist options
  • Select an option

  • Save knowtheory/1776418 to your computer and use it in GitHub Desktop.

Select an option

Save knowtheory/1776418 to your computer and use it in GitHub Desktop.
DV.model.Document = Backbone.Model.extend({
className : 'document',
url : function(){ return DV.host + '/documents/' + this.get('id') + '.json'; },
sync : function(method, model, options) {
options.dataType = "jsonp";
return Backbone.sync(method, model, options);
}
});
DV.model.DocumentSet = Backbone.Collection.extend({
model : DV.model.Document,
url : function(){
var queryStatements = this.map(function(doc){
return encodeURIComponent('document:' + doc.id);
});
return DV.host + '/search/documents.json?q=' + queryStatements.join('+');
},
sync: function(method, model, options) {
options.dataType = "jsonp";
return Backbone.sync(method, model, options);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment