Skip to content

Instantly share code, notes, and snippets.

@PabloVallejo
Created April 8, 2013 02:24
Show Gist options
  • Save PabloVallejo/5333745 to your computer and use it in GitHub Desktop.
Save PabloVallejo/5333745 to your computer and use it in GitHub Desktop.
// User model
//--------------------
models.User = Backbone.Model.extend({
defaults: {
id: 0
, username: ''
}
// Set url to always be `/login` not `/login/:id`
, url: function() {
var base = '/login';
return base;
}
// Set sync method to use POST method
// in both update and create
, sync: function( method, model, options ) {
if ( method === "update" ) method = "create";
return Backbone.sync( method, model, options );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment