Home › Forums › Calendar Products › Community Events › JS error when using Filter Bar
- This topic has 8 replies, 3 voices, and was last updated 10 years, 5 months ago by
George.
-
AuthorPosts
-
October 27, 2015 at 11:27 am #1018998
Timothy Lindsay
ParticipantI’m getting a JS error when using the Filter Bar. This is with all other plugins deactivated, and with the site reverted to the twentyfourteen theme. It causes the Filter Bar JS interactions (expanding/collapsing) to stop working.
InvalidValueError: not an Object (anonymous function)main.js:15:592 Mmain.js:19:1040 (anonymous function)tribe-events-ajax-maps.min.js:1:3298 jjquery.js:1005 fireWithjquery.js:1050 readyjquery.js:1118 Jjquery.js:1127It seems this is something to do with Maps.
As it wasn’t clear what was causing the error, I decided to start from scratch with a fresh WordPress install (using the twentyfifteen theme this time), installing the Events Calendar plugins, and then adding some events. I added the events by exporting them from the original site, and importing into the new site using the built in Export tool, and Import plugin.
It was only when I imported the events that the error began to appear again. I then realised that each of the events had the “show Google Map” and “show Google Map link” options checked, but there was no address entered. I wondered if this was causing the issue. So I disabled the Google Map in the general settings (which seems to remove the “show Google Map” link from all events), and also went through each event and unchecked “show Google Map link”. However, the error remains.
I even went as far, on the new site, as to delete all the events. Frustratingly, the error is still there, although with slightly different line numbers, probably due to using a different theme:
InvalidValueError: not an Object (anonymous function)js:37:592 Mjs:41:1040 (anonymous function)tribe-events-ajax-maps.min.js:1:3298 jjquery.js:1:27314 fireWithjquery.js:1:28123 readyjquery.js:1:29967 Jjquery.js:1:30327This has rendered the Filter Bar useless. I really hope you can help!
These sites are currently local only, I can’t give you a public link I’m afraid.
-
This topic was modified 10 years, 6 months ago by
Timothy Lindsay. Reason: wrong error message pasted, corrected
-
This topic was modified 10 years, 6 months ago by
George.
October 27, 2015 at 11:38 am #1019004Timothy Lindsay
ParticipantUpdate: Something I forgot to say in the original post: I’ve set the filter bar to be horizontal. And I’ve discovered that if I put the filter bar back to its vertical state, the options are expanded by default, and I can continue to use it! So it seems it hasn’t been rendered entirely useless then. And I can probably find a way to make sure it appears fully expanded on page load when in a horizontal state.
However, it would still be good to get this issue cleared up.
October 27, 2015 at 11:52 am #1019014George
ParticipantHey @nucreative,
Thank you for the detailed report of this! I’m really sorry this bug has hindered your use of the plugin; I’m glad vertically-displaying Filters work now as a placeholder, but you should definitely be able to use horizontal Filters as well.
I don’t personally have any JavaScript errors when I try this out on my local testing site, so I’m curious – can you link directly to the events page on your site where the above-noted errors occur? I will look at it live in person and see what I can learn.
Thank you!
GeorgeOctober 27, 2015 at 6:39 pm #1019144Brian
MemberHi,
Sorry for the issues here.
We think we have found the problem and it is due to a change in the Google Maps API.
Please add the following snippet to your theme’s functions.php:
/**
* Null values in the geoloc estimates can cause breakages with the
* current Google Maps scripts; this helps to ensure that is avoided
* by effectively casting nulls to zeroes.
*
* @param array $geocords
*
* @return array
*/
function temp_fix_geocoords_breakage( $geocords ) {
return array_map( 'floatval', $geocords );
}
add_filter( 'transient_geoloc_center_point_estimation', 'temp_fix_geocoords_breakage' );Let me know if that fixes the issue until we can get a release out.
Thanks
October 28, 2015 at 5:29 am #1019228Timothy Lindsay
ParticipantHi George and Brian – thanks for your replies on this, and for the quick fix! Look forward to seeing this patch in a new release 🙂
October 28, 2015 at 9:14 am #1019372Timothy Lindsay
ParticipantAh, turns out that fix is causing a PHP Warning:
array_map(): Argument #2 should be an arrayAny ideas on how to fix this? A PHP Notice I could probably live with until the next release, but a PHP Warning not so much!
Edited to add: refreshed the page and the warning didn’t show up this time. Will keep an eye on it.
-
This reply was modified 10 years, 6 months ago by
Timothy Lindsay. Reason: extra info
October 29, 2015 at 8:19 am #1019781George
ParticipantHey @nucreative,
Try changing the original function shared by Brian from this:
function temp_fix_geocoords_breakage( $geocords ) {
return array_map( 'floatval', $geocords );
}
To this:
function temp_fix_geocoords_breakage( $geocords ) {if ( is_array( $geocords ) && ! empty( $geocords ) ) {
return array_map( 'floatval', $geocords );
}return $geocords;
}
I hope that helps!
GeorgeNovember 2, 2015 at 9:07 am #1020847Timothy Lindsay
ParticipantHi, that seems to have done the trick – thanks!
November 3, 2015 at 9:47 am #1021361George
ParticipantNice! Stay tuned to plugin updates, we’ll be including an official fix for this as soon as possible 🙂
Cheers,
George -
This topic was modified 10 years, 6 months ago by
-
AuthorPosts
- The topic ‘JS error when using Filter Bar’ is closed to new replies.
