jeudi 28 janvier 2016

Ember 2.0 alternative for transitionTo since its deprecated

So I am trying to make a component named 'fsol-app-btn' that is an A tag link. First thing I did was change the tagName in the component.js So it properly renders on the page as an A tag.

Here is the component.js:export default Ember.Component.extend({ classNames: ['btn', 'btn-app'], tagName: 'a', num: false, color: 'aqua', route: 'dashboard', mouseDown: function() { console.log('f'+this.get('route')); //this.transtionTo(this.get('route')); this.sendAction('action', this.get('route')); } }); Here is the component's template.hbs: {{#if num}} <span class="badge bg-{{color}}">{{num}}</span> {{/if}} <i class="fa fa-{{icon}}"></i>{{title}}

Now here it is in the html:{{fsol-app-btn icon='bullhorn' title='Notifications' route='index' num='3' color='yellow'}}

icon, title, color, and num all work and are just for styling so this one component can be used for any kind of button I want.

But the button's main functionality is to click and do something, in this case I want it to go to a route, such as a link-to helper would. I tried passing a route='name of route' and then on mouseDown call this.transtionTo(this.get('route'));

But I get a deprecated warning and it doesnt work.

So how do i do this? btw: I also tried this.sendAction() and in this case I had an action called 'clicked' defined like so: {{fsol-app-btn icon='bullhorn' action="clicked" title='Notifications' route='index' num='3' color='yellow'}}

But then I got an error saying that my fsol-app-btn's parent component had no action handler for: clicked

I tried making routes all over the place in locations I thought would catch the action but to no avail.

Any ideas?




Aucun commentaire:

Enregistrer un commentaire