Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created September 18, 2009 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cowboy/189255 to your computer and use it in GitHub Desktop.
Save cowboy/189255 to your computer and use it in GitHub Desktop.
function get_hash() {
var loc = document.location;
return loc.hash ? loc.href.replace( /^.*\#/, '' ) : '';
}
if ( 0 ) {
var esh = $.event.special.hashchange = {
setup: function(){
console.log( 'setup' );
$(this).bind( 'hashchange', esh.handler );
//return false;
},
teardown: function(){
console.log( 'teardown' );
},
handler: function(e){
console.log( 'handler' );
e.hash = get_hash();
$.event.handle.apply( this, arguments );
}
};
}
$(function(){
$(window).bind( 'hashchange', function(e){
console.log( 'hashchange', get_hash(), e.hash );
});
var arr = [ 'foo', 'bar', 'baz' ];
(function loopy(){
arr.length && setTimeout(function(){
var hash = '#' + arr.shift();
console.log( 'setting hash to', hash );
document.location.hash = hash
loopy();
}, 500);
})();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment