Anchors

Andreas
Posts: 13
Joined: Mon Dec 03, 2018 3:30 am

Anchors

Postby Andreas » Thu Feb 28, 2019 4:29 am

Hi Folks,

I’m trying to simulate an HTML anchor like behaviour on a page.
It basically has the alphabet on top and topics listed on the page, by clicking on one of the letters the site is supposed to scroll/jump to the part of the (same) page with topics that start with this letter (they are sorted).
I’ve been wrecking my head and can’t get it to work. A HtmlPresenter with an id attribute doesn’t seem to work.
Any ideas how to do this?

Thanks,
Andreas

Andreas
Posts: 13
Joined: Mon Dec 03, 2018 3:30 am

Re: Anchors

Postby Andreas » Thu Feb 28, 2019 7:01 am

Found a workaround to my own question, but thought it might help someone looking for the same. If there is a better solution out there, let me know:

I add HtmlPresenters to each of the dynamically added topic headers on the page hosting a div with a unique id (in this case the first letter of the grouped topics). When clicking on a Letter HyperlinkButton, I can extract the ID from the button and execute the following JS: CSHTML5.Interop.ExecuteJavaScript("document.getElementById($0).scrollIntoView()", letter);.

A.


Return to “General Discussion and Other”

Who is online

Users browsing this forum: No registered users and 4 guests