Tell us what you are trying to do?
I have created a view and i want to add a "print" button that fires a javascript to popup the system print dialog, in the "search and pagination" section.
However, When I add the onClick attribute to the input element, the view will no longer save. If I remove the onClick attribute, the view will save again.
Is there any documentation that you are following?
I took some information from this thread:
https://toolset.com/forums/topic/ho-to-add-a-print-button/
What is the link to your site?
If you will please enable private replies, I will provide information for the specific site and the view this applies to.
Hi,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot this, I'll need to see how this view is set up in the admin area.
I've set your next reply as private, so that you can share temporary admin login details, along with details of where exactly this print button, can be seen.
Note: It is recommended to make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details, but, I'm getting an "incorrect password" message.
Can you please check the username and password again?
I've set your next reply as private.
Give it another try with the same password, please
Thank you for sharing the admin access.
I've performed some tests on my website's view, but I had no difficulty in saving the HTML code with the "onClick" attribute. It seems that the security plugin on your website is stripping the "onClick" part, thinking of it as suspicious code.
Instead of triggering the print function using the inline "onClick" attribute, you can trigger it using a separate function in the view's "JS editor" like this:
( screenshot: hidden link )
jQuery( document ).ready(function($) {
$( "input.print-button" ).click(function() {
printDiv('printableArea');
});
});
And, in the "Search and Pagination", the code for the print button will become:
<input type="button" value="Print" class="print-button">
As a result, whenever an input element with the class "print-button" will be clicked, your print function will be triggered.
This worked a treat!
My issue is resolved now. Thank you!
Worked a treat!
My issue is resolved now. Thank you!