Emberjs transitionToRoute to new tab

Total
1
Shares

I would like to make Ctrl and Meta Key possible when users click on link inside an EmberJS app.

Is that possible to open the transitionToRoute into a new tab?


Solution

Good question… If you use {{link-to}} then it will just work without any “hacks”…

But if you have to do it inside your click action then you can’t use transitionToRoute.

You can probably check if ctrl/meta keys are down (see JavaScript: Check if CTRL button was pressed)

Then you will have to use window.open(routeUrl).

You can then generate the routeUrl using router#generate, see How to generate url for a route in Ember.js

PS: I haven’t tried any of this just guessing but it already feels dirty and smells bad. I would recommend {{link-to}} if possible.

PPS: I would love to hear how you solved it 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *