In general, hash changes are created whenever a link is clicked in jQuery mobile. When a link is clicked, jQuery mobile will make sure that the link is referencing a local URL, and if so, it'll prevent the link's default click behavior from occurring and request the referenced url via Ajax instead. When the page returns successfully, it will set thelocation.hash
to the new page's relative url.
Hash changes that occur independently of a click, such as when a user clicks the back button, are handled through the
hashchange
event, which is bound to the window object using Ben Alman'shashchange
special event plugin (included in jQuery Mobile). When a hash change occurs (and also when the first page loads), thehashchange
event handler will send thelocation.hash
to the$.mobile.changePage()
function, which in turn either loads or reveals the referenced page.