I have a route defined in the Router as:
...
this.resource('cart', {path: 'my/cart'});
...
MyApp.CartRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('cart');
}
});
In my CartController (ArrayController) I have this line of code in an action (addToCart):
this.transitionToRoute('cart', this.get('model'));
In some other route's template, I call that action:
<button {{action 'addToCart' product target='controllers.cart'}}>Add To Cart</button>
When that button is clicked, I get this error:
Uncaught Error: More context objects were passed than there are dynamic segments for the route: cart
To my understanding, Ember should have recognized that I was passing it a model and skipped the model hook, which is what I want.
This can be fixed by adding a random, useless dynamic segment to my route definition then defining serialize in my CartRoute. However, if there is a better way, I would rather do that.
Am I going about this the wrong way?
Aucun commentaire:
Enregistrer un commentaire