Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/component/link-delegate

Anchor tag click delegation / negotiation for simplifying client-side routing
https://github.com/component/link-delegate

Last synced: 13 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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

```js
var link = require('link-delegate');

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

## License

MIT