Home › Forums › Add-ons › Flexible Content Field › When only one layout available, the "Add" button should not have options popup › Reply To: When only one layout available, the "Add" button should not have options popup
For now I am handling this with some simple front-end JS…
/*! FLEXIBLE CONTENT: AUTO-CLICK IF SINGLE OPTION **/
acf.add_action('ready', function($body){
$body.find('#post').on('click', 'a[data-event="add-layout"]', function(){
var $button = $(this);
var $target = $button.parents('.acf-flexible-content').eq(0).find('.clones').find('.layout');
if ($target.length === 1) {
setTimeout(function(){
var $popup = $button.next('.acf-fc-popup');
$popup.find('a').eq(0).click();
$popup.remove();
}, 0);
}
});
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.