i have a select field filled with many values filled using add_filter(‘acf/load_field/name=searchfield’, ‘my_acf_load_field’); I set the field to extended and activated the ajax mode on it.
because of the number of options, it hangs all the time even directly when i click it for the first time(without any input in it).
Can you tell me where to edit the acf-pro-input.js so it won`t start searching until at least 3 chars are filled in? Or is there another trick to make it suitable for big data collections?
Hi @niceguys
If you want to start searching after 3 chars, you can try this code:
add_action('acf/input/admin_footer', 'my_acf_admin_footer7');
function my_acf_admin_footer7() {
?>
<script type="text/javascript">
(function($) {
acf.add_filter('select2_args', function( args, $select, settings ){
args.minimumInputLength = 3;
// return
return args;
});
})(jQuery);
</script>
<?php
}
This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.
I hope this helps 🙂
Thank you very much James!