Bind to a Server Generated Link


#1

Hi. I’ve searched around for this, but I can’t work out how to accomplish it, or even quite what to search for.

I’m generating notifications on my server. So, to take a simple example, if you “follow” someone on our site, then you’ll get a notification like this:

Johnny is now following you.

I’d like to be able to generate a link to allow the followed person to click through to Johnny’s profile. Now, I can obviously easily generate a link:

<a href='/people/johnny'>Johnny</a>

But that isn’t bound to a route transition. So, how might I go about binding this on the client?

If I try something like saving the route name and params in the notification, and do this:

[{link-to notification.text notification.route notification.params}}

Where notification.route is “person” and params is “johnny”, it doesn’t link correctly. I’ve previously been able to bind routes in link-to to bound data (in the controller) but not here.

I’d like, if possible to transform the into a link-to. Is that feasible or possible? Prior art?

Thanks, Johnny


#2

I’ve ended up using an action, and have it working. However, I’m still interested to know if it’s possible to convert an tag into a link-to?

I’m using location: auto. If it was a hash, it’d work, but I get a full page request it’s not.


#3

I would definitely try to keep everything on the Ember side of life. But if you really need links generated on your server, you could compile your Handlebars templates for a component on the server and generate it at a particular path in your components directory with the appropriate {{server-side-link 'text' route param1 param2}} string inside.

This is just a thought though. I would still keep your behaviors on the client-side, and just populate Models with the appropriate data needed to generate your links.