Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Darren Hunter 134 posts 226 karma points
    Aug 15, 2024 @ 15:32
    Darren Hunter
    0

    Umbraco Block Grid

    Hi,

    Can any one advise when I render a page I can check to see what blocks have been used in out block grids.

    I am relying on some JavaScript to do some effects on a block they are firing on page load.

    let ranStatCount = false; var $this = $('#@id');

    var elementTarget = document.getElementById('@id'); var position = elementTarget.getBoundingClientRect();

    // If the elements are in the top of the page view, // increment the stat count straight away if (position.top >= 0 && position.bottom <= window.innerHeight) { IncrementStatCount($this); }

    We have added addEventListener that added to each of the blocks, that executes the above code.

    That should execure when get to a specific section of the page, but it executing on load.

    I have used the same position check in other code that runs on .ready and that correctly works when the page is set to a specific position.

    But when I use a block it not.

    Is there a way to detect if specific blocks have been used on the page, and then I can add the correct javascript on the .ready event.

Please Sign in or register to post replies

Write your reply to:

Draft