scroll to new item added to deck

  • 1
  • Question
  • Updated 1 year ago
  • Answered
I'm using a queue that executes a snippet on click. The snippet (among other things) adds a row to the end of a model. I have a deck component on that model, and I'd like to scroll the page so that the row that was just added is visible. How can I do that?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 1 year ago

  • 1
Photo of John Dahlberg

John Dahlberg, Champion

  • 2,442 Points 2k badge 2x thumb
Try using anchor navigation.  I have a similar scenario on a global search page and I've used a wrapper for each search result set with a unique Id set to the anchor target.  Then in the top of the page I display a count of results that you can jump to:

<a href="#ContactSearch">{{$Model.SearchContacts_Global.data.length}}</a>.  Add the "ContactSearch" in the uniqueId field of the wrapper.  In your case, you could use a merge value from on of the fields in context for your card. 

This should be easy enough to convert to script to perform the navigation.

I'm still working on relative positioning as the anchor positions under my header, but haven't had a chance to dig in on that yet.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Nice idea.

Turns out the row I'm adding will always be at the bottom of the page, so I'm simply scrolling to the bottom.