Skip to content

Commit

Permalink
avoid inline JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
xi committed Oct 20, 2021
1 parent a9c40ca commit 1c837f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions static/js/lagerregal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@
event.preventDefault();
}
});

$(document).on('click', '[data-print-pdf]', function(event) {
var url = $(this).data('print-pdf');
printJS({printable: url, type:'pdf'});
});
});
})();
4 changes: 2 additions & 2 deletions templates/devices/detail/device_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
</li>
{% endif %}
<li>
<button class="dropdown-item" type="button" onclick="printJS({printable: '{% url "device-generate-label" device.id %}', type:'pdf'})">
<button class="dropdown-item" type="button" data-print-pdf="{% url "device-generate-label" device.id %}">
<i class="fa fa-print"></i> {% trans "Print Label" %}
</button>
</li>
<li>
<button class="dropdown-item" type="button" onclick="printJS({printable: '{% url "device-generate-protocol" device.id "handover" %}', type:'pdf'})">
<button class="dropdown-item" type="button" data-print-pdf="{% url "device-generate-protocol" device.id "handover" %}">
<i class="fa fa-print"></i> {% trans "Print Handover Protocol" %}
</button>
</li>
Expand Down

0 comments on commit 1c837f1

Please sign in to comment.