Router templates and Components


#1

Hi,

A component has didInsertElement, why doesn’t the router template have something similar? I am trying to know when the route has rendered it’s template HBS file. I am a little tired of putting in a component into a HBS just as boiler plate. Why are router templates even any different to component.js? Shouldn’t a router just render a component?

If I had a component that is an overlay that I wanted to resize/reposition after it appears when transtioning into the route that makes it appear (with javascript,… not CSS) how would I do this?

Yes I could again put in a component, but really why should I have to?


#2

I think you’re absolutely right — this is probably how it should be. Components in Ember came onto the scene way after Routes & Controllers, so there’s a little bit of backwards compatibility being maintained here. In addition, the solution (“Routable Components”) has not landed yet and it’s not exactly clear when it will as it seems to have taken a backseat to Glimmer2. The shorter term solution, while somewhat boilerplate-y, is to do exactly what you’re doing.


#3

for foo route:

in app/views/foo.js, do:

export default Ember.Component.extend( /* stuff */ )


#4

Oooooohhhhhh. :thumbsup:


#5

I can’t remember where I picked this up! Probably on slack.


#6

Thanks Alex Speller How do you know about it out of interest?