mercredi 11 février 2015

Ember data delete nested records

I have multiple shopping carts. Every cart has multiple products.


When I trie to remove a product from a cart, generated url tries to remove a product globally not just from that specific cart.



App.IndexRoute = Ember.Route.extend({
model: function() {
return this.store.find("cart", 2);
},
actions: {
remove: function(product){
product.deleteRecord();
product.save();
}
}
});

{{#each product in model.products}}
<div>{{product.title}} <button {{action "remove" product}}>x</button></div>
{{/each}}


HTTP request generated is DELETE products/{id}


I would expect it to somehow include cart id in url. How to handle such situations ?


demo: http://ift.tt/1E0GQfV





Aucun commentaire:

Enregistrer un commentaire