Home › Forums › Backend Issues (wp-admin) › Add Event to Select2 Field › Reply To: Add Event to Select2 Field
so… I was able to find a *very hacky* solution:
(function($) {
acf.add_filter('select2_args', function( args, $select, settings, a ){
var selectId = $select.attr('id');
// this is what we need to bind the event to select2:
var $input = $('input#'+selectId+'-input');
$input.on( 'select2-selected', function (e) {
console.log( 'selected', e );
});
// return
return args;
});
})(jQuery);
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.