Skip Navigation

[Resolved] JS Stopped working

This thread is resolved. Here is a description of the problem and solution.

Problem:
I have had my custom JS code working for years, and now it seems to be not working anymore5 all of a sudden.
I see the error Uncaught TypeError: $ is not a function in the console.

Solution:
JS needs a namespace like jQuery when used in WordPress.
a $ will conflict with an increasing amount of scripts if used on WordPress

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/adding-custom-javascript-views/#achieving-great-results-with-little-coding-by-using-jquery

This support ticket is created 4 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by davidZ 4 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#1489123

A few years ago, you helped me with this topic: https://toolset.com/forums/topic/show-results-in-modal/

Client just informed me that the modals have stopped working,

Here's the page with the issue: hidden link.

Any suggestions as to what might have changed since this topic was resolved?

Thanks

#1489197

There are JS errors on this page that could block the execution of Bootstrap 3 Modals.

1. Uncaught SyntaxError: Invalid or unexpected token in your View, in the JS editor, where you add "window.addEventListener(\"load\", function() {"

2. Uncaught TypeError: $ is not a function as well in the custom JS on the line where you add "$('.dipper-poster').click(function() {"

$ is not a valid namespace, you should use jQuery or pass the namespace in the function($), please see https://toolset.com/documentation/user-guides/views/adding-custom-javascript-views/#achieving-great-results-with-little-coding-by-using-jquery

I think fixing those 2 errors will resolve the issue.

#1489347

That was it! I wonder why it worked for three years before it broke...