Skip Navigation

[Resolved] Toolset Maps view is not working and Javascript error is returned

This support ticket is created 4 years, 11 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by joseL-6 4 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1385541

This problem is the same as the issue I had on this other site
https://toolset.com/forums/topic/error-your-location-is-needed-to-show-this-content-on-a-view/

In the section "Find a Location Near You", the list of locations is supposed to display on the right of the map, in order of proximity to the user's location (yes, Allow Location must be on in the browser).

However, a Javascript error is preventing the list from displaying on both hidden link and hidden link

The Error console identifies the error as "TypeError: $ is not a function"

The last time this happened (see ticket referenced above) we thought it was a plugin conflict, because the myctdentist.com website worked, but the dentalassociatesct.com did not.

However, now BOTH sites are not working and throwing the same error. I've tried using a different theme and deactivating plugins but the error persists.

#1385553

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I checked both sites URL: hidden link and hidden link

I set my browser to share the current location and loaded both of the above site but I do not able to see the JS error you shared on the browser's console. Please check the following screenshot:
=> hidden link

Just to ensure, I asked one of my colleges to load the URL and even he do not see the JS error you said with browser console. The map is loaded without any issue.

- Can you please make sure there is no cache involved here. (browser/server)
- If you still see the issue, can you please share what browser version and Operating System you are using.
- You can share the access details so I can check if there any JS custom code added with your maps.

*** Please make a FULL BACKUP of your database and website.***
I have set the next reply to private which means only you and I have access to it.

#1385861

Hello. Yes, I worked for a while on this last night and I was able to address the issue. But I am not sure if this is really a true fix.

What I did was modify my theme to add the following code in the head of all pages:

<script>
var $ = jQuery.noConflict();
</script>

This fixed the issue. However, like I said, I'm not sure if this will fix it for good.

#1385865

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Actually, normally, if you want to wrap your code with $ you should use the proper jQuery event.

For example - this is a good practice:

jQuery(document).ready(function($){

// add your code having $ here

});
#1385875

I don't have any custom code currently on either site: so the problem code is either in the Toolset Maps plugin or another plugin. However, I tried deactivating all plugins except for the Toolset plugins and using a plain default theme, and the problem still persisted.

The only thing that fixed it was using the "var $ = jQuery.noConflict();" code.

I don't know where the code that you suggested would go. I think the script that was throwing the error was from the Maps plugin:

<script type='text/javascript'>
$( document ).ready( function() {
$( window ).load( function() {
WPViews.location.initWithReload();
} );
} );
</script>

However, I don't know for sure.

#1385927

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I see the code using $ sign and yes, the code is part of the Toolset map's plugin file at:

 plugins\toolset-maps\includes\toolset-maps-geolocation-shortcode.php

I see you are using other third-party plugins like BB, Gravity forms etc..etc.. that should use $ sign. However, the code you shared I think needs correction.
Can you please send me duplicator copy of your install so that I can pass it to our next level support for further investigation.
=> https://toolset.com/faq/provide-supporters-copy-site/

I have set the next reply to private which means only you and I have access to it.

#1386685

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing the duplicator package. I installed your site on my local test install and I found that the issue you reported is already solved with the Toolset Maps Beta 2.0 -b2 version.

In Beta version I checked the code is adjusted as given under for the same file:
=> plugins\toolset-maps\includes\toolset-maps-geolocation-shortcode.php

jQuery( document ).ready( function() {
				jQuery( window ).load( function() {
					WPViews.location.initWithReload();
				} );
			} );

We are planning to release the stable version very soon. If you want to try the Beta version of Toolset views and Maps plugin, you can download it from your account's page:
=> https://toolset.com/account/downloads/
[Select "Beta" option from Choose Channel dropdown available at top right]

#1386981

My issue is resolved now. Thank you!