Support

Account

Home Forums ACF PRO ACF Blocks – How to send data to js?

Solved

ACF Blocks – How to send data to js?

    • Sridhar

    • September 21, 2020 at 12:31 pm

    I am trying out ACF Pro to build a custom carousel block and am looking to pass the user selected option’s value to the init js file.

    screenshot

    Something like this:

    var initializeBlock = function ($block) {
    	$block.find('.gallery-carousel').flickity({
    		cellAlign: $value_selected_for_the_block,
    	});
    };

    My current code is similar to https://www.advancedcustomfields.com/blog/building-a-custom-slider-block-in-30-minutes-with-acf/.

    Any idea?

    • Sridhar

    • September 21, 2020 at 3:22 pm

    Solved by sending the field value as a data attribute and accessing it in the JS file.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.