Home › Forums › ACF PRO › Max items for post object field › Reply To: Max items for post object field
Using custom JS, stuff that’s not listed in the docs
1) Enqueue your custom JS script on the acf/input/admin_enqueue_scripts hook
2) You custom script should depend on the acf script handle acf-input
3) You initialization code should look something like this
if (typeof acf != 'undefined') {
acf.add_action('select2_init', function($input, args, settings, $field) {
// $input (jQuery) hidden input element
// args (object) args given to the select2 function
// settings (object) settings given to the acf.select2 function
// $field (jQuery) field element
// you need to check the $field element to make sure your looking at the right field
// you can use the console to see what's in vars
// for example
conole.log($field);
});
}
I found this post on the select2 argument that you probably need to set http://stackoverflow.com/questions/19789984/limit-the-jquery-select2-maximum-selected-options
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.