I recently used iron router for meteor, I have been surprised to see that browsing from one page to another using the router will actually reload the whole page content. This is due to the fact the url path to be changed while browsing from one page to another. It might be useful for websites browsable by search engines but building a web application this is not what I'm looking for.
Actually I was expecting something based on fragments where changing the fragment would for example put it in the session so that I might be using it directly in my template. The following code should produce the wanted effect (jQuery):
$(window).on('hashchange', function() {
Session.set('hash', window.location.hash);
});
But before to use my own solution I would like to ensure I'm not reinventing the wheel. Is there any meteor router or any other framework supporting page rendering based on fragments (in opposition to the path) ?
iron-router does not actually reloads the whole page as long as we are doing this through tags <a href="/somePage">ClickMe</a> or via the Router function Router.go('/somePage');
Manually introducing the url in the browser's field would however reload the whole page (which would not be the case using a fragment)
For those looking for dynamically putting the fragment into the session here is the full code I used:
function storeHashInSession()
{
Session.set('hash', window.location.hash);
}
Meteor.startup(function()
{
storeHashInSession();
});
$(window).on('hashchange', function()
{
storeHashInSession();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With