Close Content Dock with Javascript?

Hello again folks,

I have an agile form in the content dock on my homepage. I want to close the content dock after the form has been submitted, how can I go about this? There is a div which displays a success message currently when the form submits so I was thinking to monitor this for a change or something.

What code do I need to generate the close contact dock transition?

Thanks,

Stephen

Hey Stephen,

Thank you for reaching out to us. Perhaps you do something like this:

jQuery(document).ready(function($){
	$('form').on("submit", function(event) {
		$('.tco-close-content-dock').click();
	});
});

This will close the content dock on form submission but it won’t check if the form was successfully submitted or not, regretfully there is no easy way to check this case. You probably need to find the success method of your form submission and then inside the success method you can use the following code to close the content dock:

jQuery('.tco-close-content-dock').click();

Please note that the code provided above serves as a guide only and is to help you in getting started so implementing it and maintaining the code will be out of our support scope and for further maintenance for new possible versions of the theme that may cause the customization to break, you will need to hire a developer.

Thanks!

Okay that’s great thanks for the help!

You’re welcome!

Cheers.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.