jQuery address hash change trigger even if hash doesn't change -


i using plugin http://www.asual.com/jquery/address/ detecting hash changes , such website, uses navigation it's vital part of users experience. works perfect doing it, except doesn't trigger event if hash doesn't change/isn't different last hash url clicked, example if i'm on example.com/home , click homepage icon again doesn't reload page again, if using regular links does. haven't been able figure out how achieve links part of url. (not tags because use tags without being navigational part. great, thanks.

$.address.change(function(event){ ///events triggered on hash change }); 

the onhashchange event aptly named, fires when hash changes.

the solution aware of problem bind same function homepage icon's click event.

also, jquery provides it's own event hash change:

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

also, if these tags, say, in #nav div:

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

or can applied tags:

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

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -