How to use FlowRouter.withReplaceState()


#1

This is a different problem from a similar question about ‘reload’. This use case has to use ‘withReplaceState’ to handle back button reloading.

I’ve found the FlowRouter documentation for FlowRouter.withReplaceState(fn), but I’ve been unable to find specific code examples and can’t get it working.

My problem is with Isotope, a plugin that moves elements around when window is resized. User sometimes visits Isotope page, goes to another page, re-sizes window, then presses “back” button to return to Isotope page. Page has to reload to re-trigger the Isotope layout correctly for the new window size.

This is my route. How would I use FlowRouter.withReplaceState() to ensure that user who clicks back button is not seeing the cached page?

FlowRouter.route( '/work', {
  action: function() {
    BlazeLayout.render( 'body-static', { 
      content:  'work',
    });
  },
});