Deep link to a position in a page, using Meteor JS

meteor

Solution

Are you using some kind of javascript router? Meteor Router?

You could use something like a javascript based scrolling method. One such example is with JQuery: (You can place this in your link/buttons click handler)

Template.hello.events({
  'click #theitemtoclick':function(e,tmpl) {
      e.preventDefault();
      $('html, body').animate({
          scrollTop: $("#item_id").offset().top
      }, 600);
   }
});

Then tag your html item where you would put your anchor with the id:

<h1 id="item_id">Section X</h1>

Problem

I have a meteor app with multiple pages. I want to be able to deeplink to an anchor somewhere halfway the page. Traditionally, in normal html, you'd make an somewhere in your page, and link to it via /mypage.html#chapter5. If I do this, my meteor app won't scroll down to that spot. What is the best approach around this?

Original source