Using a route to scroll to part of page in parent route


#1

Hi, I have a an app with an endpoint like:

myapp.com/stories/

that renders an array of stories:

{{#each story in stories}}
    {{my-story-view model=story}}
{{/each}}

I would like to add a subroute:

myapp.com/stories/code/story/story_id

that scrolls to that story in the parent page if it exists… and does nothing if it doesn’t.

I am unclear how to proceed. I have a new route and controller for the individual story, can link to the parent controller (the array of stories), can detect if the model for the individual story exists, but can’t come up with a way to find the ‘my-story-view’ associated with the model so I can scroll to it.

Any ideas? Thanks for your help!


#2

By the way, this is closely related to another (unanswered) post I found earlier: Using page sections as routes


#3

I’ve done this. I made a gist for you: https://gist.github.com/ef4/90d1e1c37e6176c8a7e3

The gist shows my scroll-here component. Then you’d also want to set up your routes so that they all render the same template, and use the scroll-here component to scroll to the right place.