JQuery hash change address, even if the hash does not change

I use this http://www.asual.com/jquery/address/ plugin to detect hash changes, etc. for my site, it uses this only for its navigation, so it is a vital part of the user experience. Now this works perfectly for everything that I do with it, except that it does not raise an event if the hash does not change / does not differ from the last hash url that was pressed, for example, if I am on an example. com / home and click the homepage icon again, it does not reload the page again, for example, if you use only normal links. I could not figure out how to achieve this for all links that are part of the URL. (not only all tags, because I use tags without being the navigation part, so any help would be great, thanks.

$.address.change(function(event){ ///events to be triggered on hash change }); 
+4
source share
1 answer

The onhashchange event is exactly named, it fires only when the hash changes.

The only solution I know of for this problem is to associate the same function with the event of a click on the icon of the main page.

In addition, jQuery provides its own event for changing the hash:

 $(window).on("onhashchange", function (e) { route(); }) $(".icon").on("click", function(e) { location.hash == "#/" ? route(): null; }) 

Also, if these are tags, say in the #nav div:

 $("#nav").delegate("a", "click", function () { location.hash == this.href ? route() : null; }) 

Or it can be applied to all tags:

 $("a").on("click", function () { location.hash == this.href ? route() : null; }) 
+5
source

All Articles