baseprime / grapnel

The smallest JavaScript router with named parameters, HTML5 pushState, and middleware support
http://grapnel.js.org
468 stars 40 forks source link

Anchor navigation with pushState : true not seems to be working #66

Closed pravin-d closed 6 years ago

pravin-d commented 8 years ago

I'm trying to develop an application with HTML5 push state. Anchor navigation with hash seems to work. However not able to seem to make work with HTML5 push state (maybe use custom click listener ?)

Juul commented 7 years ago

I don't think this is built into grapnel. You can add it with something like:

  document.addEventListener('click', function(e) {
    if(e.target.tagName === 'A' && e.target.href && e.target.href !== '#') {
      e.preventDefault();
      router.navigate(e.target.href);
    }
  });