• Resolved Anonymous User 11986954

    (@anonymized-11986954)


    Using Dynamic Renderer I can easily include a JS file to load when the flexible block is present in the page.

    Inside the JS, how can i reference the current block? Let’s say I have a slider inside to initialize, what’s the recommended way to do it? Can i pass some variables like ad id? Is there anything built in? Without this information having conditionally loaded js seems not very useful.

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback and sorry for the late answer, I’m kinda busy with the upcoming patch lately.

    Unfortunately there is no JS framework builtin for each Flexible Content Layout. Since the front-end render is fully handled by the developer. Some users will include an ID and class and some will not.

    As shown in the Flexible Content Dynamic Render documentation, here is template example that can be used, but it’s not mandatory:

    <div class="layout-hero <?php echo ($is_preview) ? 'is-preview' : ''; ?>">
    
        <h1>Hero</h1>
        
        <h3><?php the_sub_field('text'); ?></h3>
        
    </div>

    You could indeed add an ID and use it as a reference in your JS file. Using the Layout JS file enqueue will guarantee you that the file will be enqueued when the layout will be displayed on the front-end tho.

    I hope it’s now more clear!

    Have a nice day!

    Regards.

Viewing 1 replies (of 1 total)

The topic ‘Dynamic Renders JS’ is closed to new replies.