Skip to content

Anchor tag click delegation / negotiation for simplifying client-side routing

Notifications You must be signed in to change notification settings

component/link-delegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

link-delegate

Anchor tag click delegation / negotiation for client-side routing. This component makes it easy to implement application-wide push-state link handling without manually performing a router dispatch.

Installation

$ component install component/link-delegate

Example

The callback is invoked with an Event when the link:

  • is not x-domain
  • is the primary "mouse" button
  • does not have e.defaultPrevented (to opt-out)
  • does not specify a target
  • does not have the meta, ctrl, or shift key pressed
var link = require('link-delegate');

link(function(e){
  // perform your routing here
  e.preventDefault();
  console.log(e.target.href);
});

License

MIT

About

Anchor tag click delegation / negotiation for simplifying client-side routing

Resources

Stars

Watchers

Forks

Packages

No packages published