Thanks, that worked perfectly. 🙂
Just two minor follow up questions: Currently I see no way to translate the part "Please enter 1 or more characters" since it is not yet included in the messages box of the CRED form as an optin. I tried to change it with a Jquery but I fear it fires too late. This did not work:
jQuery(document).ready(function(){
jQuery('.toolset_select2-results__message').text('ICH BIN EINE NEUER TEXT');
});
Furthermore. I dont want to reveal the whole list too easily. WI want the user to type in at least 4 characters to trigger the search process. Which file sets this so I can adapt it even if I have to hardcode it.
Thanks in advance 🙂
From the previous ticket:
Ok i found the hardcoded text in this file:
/wp-content/plugins/cred-frontend-editor/vendor/toolset/toolset-common/res/lib/select2/select2.js in line 4484
var message = 'Please enter ' + remainingChars + ' or more characters';
I also found the variable minimumInputLength which seems to be crucial for this. It is set in line 3745:
this.minimumInputLength = options.get('minimumInputLength');
When i hardcode this as well it already works:
this.minimumInputLength = 4;
But where can I set it generally since it seems like this value is stored somewhere?
Thanks in advance ?
I use the CRED beta.
I tried to change it with a Jquery but I fear it fires too late.
In general, you should use a window load event handler instead of the document ready event handler to trigger your JS:
jQuery(window).bind('load', function(){
jQuery('.toolset_select2-results__message').text('ICH BIN EINE NEUER TEXT');
});
As far as customizing the minimumInputLength, the value is set in the code when each select2 object is initialized as part of that initial config. I can't recommend making changes to core code, but I can reach out to the team to see if it's possible to control this value with a shortcode attribute or other filter. I'll check on the translation of this string as well, please stand by and I will update you soon.
After discussion with the team, our developers decided that neither the text translation nor the minimum number of characters in the autosuggest field are currently manageable, so I should file these two suggestions as feature requests. I've started that process now, but I can't say for sure when the developers will decide to implement them. If I receive any additional information about those, I'll let you know here.