Home › Forums › Add-ons › Flexible Content Field › Confirm delete on flexible content field row
It would be nice if there was an “Are you sure?” confirm message when you click the X or delete icon on a flexible content field row. Can you recommend a way to implement this?
Hi @jason@epagecity.com
You can easily add this via some custom jQuery on the page.
Just add an .on('click')
event to the elements (via their class) and the use the confirm
JS function to make a prompt.
I’ll think about adding this to the core, but for now, a custom script will be the fastest way to see this implemented.
Thanks
E
Thanks Elliot. How do you queue up a jquery script to only run on pages that have the flexible content fields?
Hi @jason@epagecity.com
You can use this action to enqueue scripts/styles for a page which displays custom fields – http://www.advancedcustomfields.com/resources/actions/acfinputadmin_enqueue_scripts/
Hi,
i tried something like that
var $ = jQuery;
$(document).on('click', '.acf-flexible-content .acf-fc-remove', function(e)
{
if(confirm("you are about to delet an element!")){
}else{
e.stopImmediatePropagation();
return false
}
});
but the click event of the field is still triggered and the row gets deleted.
any hints on that?
I’d like to see this baked in, too. Or maybe as an option when creating the flexible content field.
I had the same results as l.pirondini, but I admittedly didn’t spend more time trying to figure it out.
Hi everyone!
Thanks Elliot for the tip, but from a user’s point of view that functionality should be native.
You should always prevent users to delete content by accident.
All our clients are complaining about this. They just don’t understand, especially the fact that the delete button is so close from the toggle button.
Do you plan to ship this functionality soon?
Anyway, thank you very much for your great, essential work.
The topic ‘Confirm delete on flexible content field row’ is closed to new replies.
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.