JS error when using Filter Bar

Home Forums Calendar Products Community Events JS error when using Filter Bar

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1018998
    Timothy Lindsay
    Participant

    I’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:1127
    

    It 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:30327
    

    This 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 8 years, 6 months ago by Timothy Lindsay. Reason: wrong error message pasted, corrected
    • This topic was modified 8 years, 6 months ago by George.
    #1019004
    Timothy Lindsay
    Participant

    Update: 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.

    #1019014
    George
    Participant

    Hey @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!
    George

    #1019144
    Brian
    Keymaster

    Hi,

    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

    #1019228
    Timothy Lindsay
    Participant

    Hi George and Brian – thanks for your replies on this, and for the quick fix! Look forward to seeing this patch in a new release 🙂

    #1019372
    Timothy Lindsay
    Participant

    Ah, turns out that fix is causing a PHP Warning:

    array_map(): Argument #2 should be an array

    Any 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 8 years, 6 months ago by Timothy Lindsay. Reason: extra info
    #1019781
    George
    Participant

    Hey @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!
    George

    #1020847
    Timothy Lindsay
    Participant

    Hi, that seems to have done the trick – thanks!

    #1021361
    George
    Participant

    Nice! Stay tuned to plugin updates, we’ll be including an official fix for this as soon as possible 🙂

    Cheers,
    George

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘JS error when using Filter Bar’ is closed to new replies.