Skip to content

Instantly share code, notes, and snippets.

@balupton
Last active September 5, 2015 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balupton/515814 to your computer and use it in GitHub Desktop.
Save balupton/515814 to your computer and use it in GitHub Desktop.
Answer: How to bind jQuery History state dynamically in .click()
//Attach event to reference nav.
$("#refnav A").each(function(a,b) {
var $b = $(b),
href = $b.attr("href");
$.History.bind(href,function(state){
loadMenu("diagram",state);
});
$b.click(function(event){
event.preventDefault();
return false;
});
});
//Attach event to reference nav.
$("#refnav A").each(function(a,b) {
$(b).click(function(){
href = $(b).attr("id");
$.History.bind(href,function(state){
loadMenu("diagram",href);
});
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment