Home Forums ACF PRO Trigger a blank row in a flex content on button click


Trigger a blank row in a flex content on button click

  • Hi,

    I’m trying to create a blank flex content row on click. I have example images of what the various layouts do inside another message field. Ideally, what I want to happen is – the user could click one of these images and have it add the appropriate layout. However, I’m only able to get the layout modal to pop open and can’t seem to trigger a click on the layout. Any suggestions?

    example of user clicking on image and modal opening

    Thank you!

    acf.add_action('load', function( body ){
    //layout button
        var layout = jQuery('.acf-field-56eadfd19457f a.acf-button.button.button-primary').filter('[data-event="add-layout"]').filter(function() {
            return jQuery(this).text() == "Add Layout";
        jQuery(' document ').on("click", ('.acf-field-56eadfd19457f'), function(){
            var popup ='.acf-fc-popup');        
        //on click of image
        jQuery('.acf-field-56ec11026a0f4').click(function() {
  • I’m replying because I don’t think that you’re going to get anything that will tell you exactly what to do. Working on the JS side of ACF is not something there is a lot of information about. I’m not even sure that what you’re trying to do is possible.

    If I had to do this I would start by looking in the file
    In this file on about line 523 you’ll find

    acf.fields.flexible_content = acf.field.extend({

    This is where the code for the flex field can be found. In this section you’ll find two functions that do this in ACF. _open is the function that opens the window and _add is the function that adds the layout. You’re going to have to somehow recreate what these two functions do.

    I’ve looked at it and to be honest, there’s too much work there for me to try it. Honestly, I wouldn’t go to that much trouble to save a user a click. There’d need to be a more important reason.

  • Thank you! I absolutely agree that it’s more work than needed, I’ll communicate this to the designer.

  • I don’t generally have designers designing the back end of WP. I do my best to make it as easy to use as possible for the client, which is why I use ACF, but beyond that… I wish you luck. It seems like an interesting project, but very time consuming.

  • This reply has been marked as private.
  • This reply has been marked as private.
Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Trigger a blank row in a flex content on button click’ is closed to new replies.