Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created January 25, 2012 15:02
Show Gist options
  • Save toastdriven/1676651 to your computer and use it in GitHub Desktop.
Save toastdriven/1676651 to your computer and use it in GitHub Desktop.
// Set ``Resource.Meta.always_return_data = True`` first, then...
var relative_root = '/api/v1/';
window.HelmModel = Backbone.Model.extend({
urlRoot: relative_root,
base_url: function() {
var temp_url = Backbone.Model.prototype.url.call(this);
return (temp_url.charAt(temp_url.length - 1) == '/' ? temp_url : temp_url+'/');
},
url: function() {
return this.base_url();
}
});
window.HelmCollection = Backbone.Collection.extend({
parse: function(response) {
this.recent_meta = response.meta || {};
return response.objects || response;
}
});
// Sample usage:
window.Entry = HelmModel.extend({
urlRoot: relative_root+'entries/'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment