Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/dubbs/jquery-printevents

This plugin publishes jQuery events before and after print
https://github.com/dubbs/jquery-printevents

events javascript jquery jquery-plugin print publish-subscribe pubsub

Last synced: about 6 hours ago
JSON representation

This plugin publishes jQuery events before and after print

Awesome Lists containing this project

README

        

# jQuery Print Events

This plugin publishes jQuery events before and after print. It normalizes [onbeforeprint](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint)/[onafterprint](https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint) and [window.matchMedia](https://developer.mozilla.org/en/docs/Web/API/Window/matchMedia) using techniques described in this [article](https://www.tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/).

## Usage
Include dependencies:
```html

```
Create subscribers for the published events:
```js
$(document).on('print:before', function () {
// run code before print
});

$(document).on('print:after', function () {
// run code after print
});
```