ember.js - Using transitionToRoute, passing a route without a dynamic segment the current model causes error -


i have route defined in router as:

... this.resource('cart', {path: 'my/cart'}); ...  myapp.cartroute = ember.route.extend({     model: function(params) {         return this.store.find('cart');     } }); 

in cartcontroller (arraycontroller) have line of code in action (addtocart):

this.transitiontoroute('cart', this.get('model')); 

in other route's template, call action:

<button {{action 'addtocart' product target='controllers.cart'}}>add cart</button> 

when button clicked, error:

uncaught error: more context objects passed there dynamic segments route: cart 

to understanding, ember should have recognized passing model , skipped model hook, want.

this can fixed adding random, useless dynamic segment route definition defining serialize in cartroute. however, if there better way, rather that.

am going wrong way?

in

this.transitiontoroute('cart', this.get('model')); 

you're sending data object route cart doesn't have dynamic segment. error message should disappear line

this.transitiontoroute('cart'); 

that said, i've got feeling architecture of application might improvable. i'd need more code sure. anyway, should have if putting action handler somewhere else , using bubbling actions without target option. again, that's feeling, don't know enough of code sure.


Popular posts from this blog