A wrapper event for both hashchange and popstate
The navigate event is a wrapper around both the hashchange
and popstate
events. In addition to providing a single event for all browsers it also provides a data object in both cases allowing for the unification of handlers. This feature is used by the $.mobile.navigate
method to include directionality and URL information.
Examples:
Change the hash fragment twice then log the data provided with the navigate event when the browser moves backward through history. NOTE: The state will not be provided by default in browsers that only support hashchange. For that functionality please see the navigate method docs.
// Bind to the navigate event $( window ).on( "navigate", function( event, data ) { console.log( data.state ); }); // Trigger a navigate event by pushing state window.history.pushState( { foo: "bar" }, "Title", "http://example.com/#foo" ); // From the `navigate` binding on the window, console output: // => {} // Trigger a navigate event by pushing state window.history.pushState( {}, "Title", "http://example.com/#bar" ); // From the `navigate` binding on the window, console output: // => {} // Trigger a navigate event by moving backward through history window.history.back(); // From the `navigate` binding on the window, console output: // => { foo: "bar" }
Please login to continue.