Page 1 of 1

Anchors

Posted: Thu Feb 28, 2019 4:29 am
by Andreas
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

Re: Anchors

Posted: Thu Feb 28, 2019 7:01 am
by Andreas
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.