Home › Forums › Front-end Issues › acf_form_head and color picker after ajax load › Reply To: acf_form_head and color picker after ajax load
Hi @tempranova
Firstly, make sure all the ACF scripts and styles are being loaded on the page, then when you AJAX request places the new html into the DOM, you will need to run a JS action on the new DOM elements.
Please note that in v5, this JS action will change, but for now it is a jQuery event called ‘acf/setup_fields’
You can read about how to use it here:
http://www.advancedcustomfields.com/resources/tutorials/adding-custom-javascript-jquery-for-fields/
To trigger the event on your new jQuery elements, use it like so:
var $el = $('.new-HTML-elements');
$(document).trigger('acf/setup_fields', [ $el ]);
Thanks
E
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
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.