Setting scrollpos for div in child template through FlowRouter param

Hi!

I have a template that calls a child template in Blaze.

<template name="tracker">
    {{>child}}
</template>

This child template then has a div that contains a scrollable table.

<div id="myDiv">
    TABLE_GOES_HERE
</div>

I intend to send out email links to this parent template with a param (called scrollpos) that can scroll the table by default to a location that will be convenient for the user.

i.e. /parent/PARENT_ID?scrollpos=1234

However, I cannot seem to get this to work consistently.

In my child template’s onRendered I was attempting this…

$('#myDiv').scrollTop(FlowRouter.getParam("scrollpos"));

But this doesn’t seem to work. I’ve gotten it to work by hardcoding a scrollpos, but even then things don’t seem to be consistent.

I’m wondering if it’s something due to the child and parent templates or with onRendered vs onCreated.

Or – should I make scrollpos a ReactiveVar, put it in a helper and then use that in the template instead?

Thanks