Skip to content

Instantly share code, notes, and snippets.

@iampeterbanjo
Created October 29, 2010 23:43
Show Gist options
  • Save iampeterbanjo/654675 to your computer and use it in GitHub Desktop.
Save iampeterbanjo/654675 to your computer and use it in GitHub Desktop.
example of using bbq jQuery plug-in
//listen for hash tag changes so we can remove the popup
$(window).bind('hashchange',
function(event){
//did we add or substract the hash?
var currentHash = window.location.hash;
currentHash = currentHash.slice(1);
if(window.console && debug){
console.log(['listings.js: hashchange event detected. currentHash is ', currentHash ].join(''));
}
if(currentHash === 'close' || currentHash === ''){
//remove event listener to prevent premature trigger
$(window).unbind('hashchange');
if(window.console && debug){
console.log('listings.js: haschange event unbound ');
console.log(['listings.js: haschange event.trigger is ',event.target].join(''));
}
$("#button").trigger('click');
} else {
if(window.console && debug){
console.log('hash is not empty. doing nothing.');
}
}
event.preventDefault();
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment