With Guide Templating V2, you'll need to import a jQuery library if you want to use jQuery statements in a theme in place of vanilla JavaScript.
This guidance is for instructional purposes only, and if you have any jQuery issues, see the official jQuery site.
To install or upgrade jQuery in your Help Center themes
- In Guide, click the Customize design icon (
) in the sidebar.
- From the theme you want to work with, click Customize.
- Click Edit code.
- Click document_head.hbs.
- Add a <script> function to point to your jQuery library, for example:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" crossorigin="anonymous" async></script>
The jQuery library is loaded, and you can include jQuery statements in your Help Center themes.
9 Comments
Hey george jackson,
The easiest way to solve the problem you are seeing is to remove the keyword async from the line you copied.
That will make sure that jquery is always loaded before you use it.
Hope this helps
Hello Sirin Sezer,
Welcome to the Zendesk online Community!
To be honest, It has been a while that jQuery was removed in the newer theme. If you really want to use jQuery, I would suggest you need to implement it as you would do on any other websites. Fortunately, you can use this through jQuery CDN: w3schools.com/jquery/jquery_get_started.asp
Let me know if you have any questions! :)
We were using the codes from below article for V1
Now we are in a way to create a new HC from scratch in V2 but below codes are not working
any idea?
https://support.zendesk.com/hc/en-us/articles/115002860148-Disabling-the-subject-and-description-fields-on-the-new-request-form-in-Help-Center-
I'm seeing a random/intermittent error with using jquery. I added the above to document_head.hbs, and then added some jquery code to script.js.
And it works fine.....until it doesn't. The error in the console log: "$ is not defined" as if jquery wasn't loaded.
The way I can repro, is to go to: https://.....zendesk.com/hc/en-us/requests/new
And just keep hitting submit. Because of the required fields, it keeps erroring and the form redisplays. You can do this several times, no problem, everything is fine, and then maybe after 8 times I run into "$ is not defined". Very weird. I've seen this on Chrome and Safari, on both mac and windows.
Any ideas?
Thanks Augusto, but why would the article say use async? Is it just a mistake?
Sophie, this is great and saved us from an issue we were facing when transitioning from an older to a newer theme post-upgrade. Thank you!
--Sam
Hello
Why V2 does not have jQuery library when published?
Hi Erika Camille Sundian
It has been a while that jQuery was removed in the newer theme. How long ago this has been removed? and is it also affecting V1?
Sirin
Hi there Sirin,
jQuery was removed last February 24, 2020 and I don’t believe it is available in v1 anymore.
It sounds like you are trying to use jquery code, I would recommend you upgrade to the latest, supported v2 Templating, and import jquery as demonstrated in this article that we are currently on.
Hope this helps!
Please sign in to leave a comment.