Skip Navigation

[Resolved] onclick attribute prevents saving

This support ticket is created 3 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by jamesR-13 3 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#2188029

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.

#2188497

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

#2189469

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.

#2189841

Give it another try with the same password, please

#2190775

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.

#2193131

This worked a treat!

My issue is resolved now. Thank you!

#2193205

Worked a treat!

My issue is resolved now. Thank you!