I am familiar with the classic method of linking to sections on your webpage, whereby the anchor tag is made to point to some elements id within the page, like this sample
<div class="main" id="section1">
<h2>Section 1</h2>
<p>Click on the link to jump to section 2.</p>
<a href="#section2">Click Me</a>
</div>
<div class="main" id="section2">
<h2>Section 2</h2>
<p>Click on the link to jump to section 1.</p>
<a href="#section1">Click Me</a>
</div>
But when I tried this trick within a Framework7 app, it didn't work. I guess it has to do with how Framework7 handles links and views, but I don't have any ideas on how to fix it. Please anyone with some experience or tips help me out.
I found an answer that works on stack overflow a day later (see link below), however I didn't want to bother to answer my own question, but I've decided to do that now.
The solution lies with programmatically scrolling the desired element/section into view with JavaScript scrollIntoView method available on every DOM element.
In a Framework7 app, the scrollable container is the element with
.page-contentclass, not thehtmlorbodytag. This was the cause of the shortcomings of the classic method which presupposes the scrollable container to be thebodytag, unlike JavaScript scrollIntoView method which looks for the closest scrollable ancestor of the section.