I have an ACF Select field (with Stylized UI set to Yes) that I need to be able to call select2 commands on.
To gain a reference to the fields I used an acf js filter.
var $expirationSelect2;
acf.add_filter('select2_args', function( args, $select, settings ){
if ( settings.key === "field_57d1ce76b8a84" ) {
$expirationSelect2 = $select;
}
// do something to args
// return
return args;
});
From my understanding, this should allow me to later call things like:
$expirationSelect2.select2("open");
But nothing works. I know acf has wrapped select2 a bit but I don’t know if that wrapper has an api I should be using instead. Please help.
UPDATE: apparently the actual selector is a sibling of the <select>
tag.
$expirationSelect2.siblings('input').select2("open");
appears to work.