Linking to another section on the same page within a code block

Hi all,

I have an accordion at the bottom of my page, but wanted to include a link in one of the drop downs that scrolls back up to a different section. I’ve tried doing this the typical html way with an anchor link and an ID, which didn’t work. I also tried using the Readymag ID, as well as the data anchor link position that RM uses for creating the page jump links, but no luck with that either. Wondering if there is a way to do this?

Thanks in advance!!

hey,
if I´m getting you right: You want to add an anchor link onto a customcode created text/button?

On solution:
Add a hidden RMshape with the desired anchorpageposition.
Get the data-ID of it.
Add a jquery/javascript function, that says: if clicked text/button inside accordeon code → trigger click the hidden RMshapeanchorbutton.

This is a approach I would follow. Its a bit hacky though, but should work. And you will always have the right position.

Another option would be to use this code snippet inside your before/body section.
Which is setting the scroll position manualy via code. This position is not the same as the RManchorlink position and you need to try+error the exact position. Also keep in mind, that, if you have a mobile version, this code has to be extended with a mobile detection and another scroll position.

but here the code snippet, which can also give you an idea to write the above option 1.

<script> 
 setTimeout(function() {

//exchange the data-id to your element, whether its data-id or a custom code element.
$("[data-id=634e5573e9f5d20038ccc1a3]").on('click', function() {
// change the scrollTop: position and duration of the scoll to your values                    
    $(".content-scroll-wrapper").animate({scrollTop:414},{duration: 1000,easing: 'easeInOutQuad'});
    });
   
   }, 1500); 
</script>

(and I think the animated element, (here “.content-scroll-wrapper”) could change to “html, body” depending on your general page alignment, if horizontal or vertical)

Thank you so much for this! This solution makes sense. I tried giving the anchor link an ID and using that as the click but wasn’t able to get it to work. To be honest my js/jquery is pretty rusty these days. I do have a RM nav link that already scrolls to that section so I thought I could try having the anchor link just trigger a click of that element, but wasn’t sure if I would use the data-id of the div container, or the data-page-id of the anchor link, or something else to target that link.