meteor - How do I force iron-router to react when the hash has not apparently changed? -


when using iron-router scroll hash using anchor button referencing id of next section, such this:

<a class="button" href="{{pathfor 'home' hash='about'}}">  

iron-router happily takes section first time button clicked.

if scroll using mouse , click same button second time, no scrolling takes place.

i presume because destination apparently same current router location, hence no reaction triggered.

how can force reaction?

i've tried clearing hash in window.location in override scrolltohash function:

router._scrolltohash = function(hash) {   var section = $(hash);   if (section.length) {     var sectiontop = section.offset().top;     $("html, body").animate({       scrolltop: sectiontop     }, "slow");   }   window.location.hash = ''; }; 

and allows second click no more, has me puzzled.

setting window.location.hash space rather empty string works:

router._scrolltohash = function(hash) {   var section = $(hash);   if (section.length) {     var sectiontop = section.offset().top;     $("html, body").animate({       scrolltop: sectiontop     }, "slow");   }   window.location.hash = ' ';  }; 

probably setting non-existent hash also.

in addition cover cases there menu link can activated second page take hash need package:

meteor add okgrow:iron-router-autoscroll 

used in combination covers every case have thought of.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -