Skip to content

Using the deferred option to set up a callback after printing

Sathvik Ponangi edited this page Nov 15, 2016 · 2 revisions

jQuery.print has the deferred option where you can pass a jQuery Deferred object with multiple callback functions attached, which is always resolved after the actual printing has been triggered.

##Example:

jQuery(function($) {
    'use strict';
    var myCallBack = function() {
        console.log('printing complete - first callback');
    }, mySecondCallBack = function() {
        console.log('printing has been completed - second callback');
    };
    $('#myElement').print({
        deferred: $.Deferred().done(myCallBack, mySecondCallBack)
    });
});
Clone this wiki locally