Print using Trigger Button

If you want your trigger button to act as a print button.

See Trigger Buttons page for how to style action links as trigger buttons. If you need to use a trigger button to act as a print button that cannot be accomplished with a menu button this is one way to accomplish it.

This is more or less the same as Print using Menu Button except for some extra CSS.

The JS

Add the following code and modify line 12 to the view number.

/***************************************/
/***** Print Trigger Button ************/
/***************************************/
function printTriggerButton(view_id) {
  $(document).on('knack-view-render.' + view_id, function(event, view, data) {
      $('#' + view_id + ' .kn-details-link').click(function(e) {
        window.print();
      });
  });
}

printTriggerButton('view_XXX'); // Set the details view number 

Keep in mind that whatever view you set will apply the window.print() action on click of any details trigger button, so keep the print trigger button the only button in the details view.

The CSS

Change line 2 to the view number the trigger button lives in. This will set all detail fields in the specific view number as display:none

@media print {
  #view_XXX {
    display:none;
  }
}

Last updated