Home Forums Backend Issues (wp-admin) Generating a preview in admin options page Reply To: Generating a preview in admin options page

  • This can be done using JavaScript.,

    I’ve built something like this, but not for repeater fields, and not for buttons. I’m working on a reviews plugin and allowing the admin to set the colors and some other style features.

    I use a message field for the preview.

    I also have several other fields. Each of these fields has several specific classes, one class that designates that it is a setting field and one that designates what the setting is. For example, all of the fields have a class “star-setting”. Basically, there is an JS action hooked to this class so that if any of the setting fields is altered it triggers an refresh of the preview.

    $('').on('change', function(e) {update_star_preview()});

    Then using JS I get all the values of the field and populate that message field with the Preview.

    There is also an action that runs when the page is ready that initializes the preview with the current settings.

    Working with repeaters would be a little more difficult because you also need to deal with rows. This can be done by getting the closest row… this code is not exact, it is just an example.

    var row = field.closest('.acf-row');

    then you can find the field is that row

    var field_1 = row.find('');

    You can use this to get the field key information and then field methods from the JS API to get the value of the field.

    Not sure how much help that is to you.