Skip to content

Instantly share code, notes, and snippets.

@jblanche
Created November 8, 2013 10:11
Show Gist options
  • Save jblanche/7368979 to your computer and use it in GitHub Desktop.
Save jblanche/7368979 to your computer and use it in GitHub Desktop.
Favorites

Pour moi le plus simple à gérer ce serait on a une hive

/hives/{id}

qui nous a renvoyer

{
  "_links": {
    "favorite": "/hives/2/favorites/{userId}"
  }
}

et dans le model hive :

addFavorite: function(){
  Backbone.sync('create', this, {
    url: expandURL(this._links.favorite, {userId: 3})
    });
},

removeFavorite: function(){
  Backbone.sync('delete', this, {
    url: expandURL(this._links.favorite, {userId: 3})
    });
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment