• Resolved imcheery

    (@imcheery)


    Hi,

    When multiple widgets with calendar (or widget and the calendar itself) are used on a page (two same widgets for desktop/mobile responsive design, for example), each creates its own <script data-js="tribe-events-view-data" type="application/json"> block, while the script is not able to deal with the array of the repeating JSONs breaking JSON.parse with an error (all JSONs from the blocks concatenated into one string):

    t.setup = function(n) {
    const i = e(n);
    if (!i.is(t.selectors.container))
    return;
    const s = i.find(t.selectors.dataScript);
    let a = {};
    s.length && (a = JSON.parse(s.text().trim())),
    t.initTasks(i, a)
    }

    The easiest solution is to assume that s can have more than a single element and verify that the same data was not already parsed before.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support tristan083

    (@tristan083)

    HI @imcheery ,

    Thank you for reaching out.

    To help us better understand the sitaution, could you please share the direct URL to the page you’re having issues with? Please do not share any credentials, this is for us to adhere to the WordPress Forum Guidelines.

    Looking forward to helping you with this one.

    Thread Starter imcheery

    (@imcheery)

    No, I can not – it is not public yet.

    I looked closely into the problem, only multiple same widgets on the same page create this problem, not the calendar itself.

    I added the widget with featured events to the header of the Astra theme, which doubles them for desktop and mobile version. Browser console showed a couple of errors related to the JSON parsing. Looked into the HTML code, found that every widget (2 in total) adds it’s own code (cut to reduce space):

    <script data-js="tribe-events-view-data" type="application/json">
    {"slug":"widget-events-list","prev_url":"","next_url":"","view_class": ..</script>

    Two same errors are in the console: Uncaught SyntaxError: Unexpected non-whitespace character after JSON at position 5149 (line 2 column 1) because variable s is an array with 2 same elements. The code s.text() combines them into invalid JSON string {...}\n{...}

    Two errors are due to the same javasript code for widgets inserted twice – function initBreakpoints:

    var container = document.querySelectorAll( '[data-view-breakpoint-pointer="UUID"]' );
    if ( ! container ) { return; }
    window.tribe.events.views.breakpoints.setup( container );

    container has 2 elements in array as there are two same DIVs with the same data-view-breakpoint-pointer

    • This reply was modified 3 months, 1 week ago by imcheery.
    Plugin Support Darian

    (@d0153)

    Hi @imcheery

    Thank you for reaching out and sharing your findings regarding the issue.

    To help us accurately reproduce the problem on our end, could you please provide detailed steps we can follow? Additionally, are you using a shortcode for the calendar widgets you mentioned?

    Your input will help us investigate further. If you have any other details or questions, please let us know.

    Thread Starter imcheery

    (@imcheery)

    Hi @d0153

    1) Fresh WP
    2) Astra Theme + The Events Calendar plugin + 1 future event
    3) Customize header, add Widget 1 with the Events List block into menu in Desktop view, add the same Widget 1 into the Mobile view. Both will be present on the same page at the same time (only one is visible) with the same UUID in data-view-breakpoint-pointer attribute.

    Result:

    Uncaught SyntaxError: Unexpected non-whitespace character after JSON at position 5265 (line 2 column 2)
    at JSON.parse (<anonymous>)
    at Object.setup (breakpoints.statopt_ver.1765957124.js:1:1382)
    at HTMLDocument.initBreakpoints (s-qgzw3lyh9g79/:253:42)

    and

    Uncaught SyntaxError: Unexpected non-whitespace character after JSON at position 5265 (line 2 column 2)
    at JSON.parse (<anonymous>)
    at Object.setup (breakpoints.statopt_ver.1765957124.js:1:1382)
    at HTMLDocument.initBreakpoints (s-qgzw3lyh9g79/:423:42)
    • This reply was modified 3 months, 1 week ago by imcheery.
    Plugin Support Darian

    (@d0153)

    Hi @imcheery

    Thank you for getting back to us and sharing those additional details.

    I’ve reviewed the issue and was able to reproduce it using both the Astra and Twenty Twenty One themes. To ensure this gets addressed, I’ve created an internal ticket (TECTRIA-1481) and included your specific use case so our team is fully aware.

    We prioritize bugs by taking into consideration the number of users impacted as well as how the bug impacts one’s ability to run an event/sell tickets. I don’t have a specific timeline as to when this issue will be resolved, but trust that our team is aware. Our team communicates updates and bug fixes in our newsletter and via our changelog.

    I’m happy to help if any other questions are coming up around this topic, otherwise I’ll go ahead and close this ticket.

    Thanks again for reporting this issue and for using The Events Calendar! Have a great day.

    Internal Bug Ticket Reference: TECTRIA-1481

    Plugin Support Darian

    (@d0153)

    Hi there,

    It looks like we haven’t heard back from you in a while, so I’ll go ahead and close this thread for now. Rest assured, we will update you through this thread as soon as the fix is out.

    If you still need assistance, feel free to reopen this thread or start a new one.

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.