The JS initialization script was moved from renderHead to Select2Behavior which is burned into the
AbstractSelect2Choice as a private final added in the constructor.
I would add a protected method, something like getSelect2Behavior which would return the select2Behavior, but will allow us to override it (maybe restrict to the Select2Behavior).
The JS inside could also be made customisable. Alternatively the string can be amended without overrides, though Select2Behavior settings.
Currently we have to do some hacking to get rid of default behavior, to add our slightly customized JS:
Optional<? extends Behavior> select2Behavour = getBehaviors().stream().filter(behaviour -> behaviour instanceof Select2Behavior).findFirst();
if (select2Behavour.isPresent()) {
remove(select2Behavour.get());
}
The JS initialization script was moved from renderHead to Select2Behavior which is burned into the
AbstractSelect2Choice as a private final added in the constructor.
I would add a protected method, something like getSelect2Behavior which would return the select2Behavior, but will allow us to override it (maybe restrict to the Select2Behavior).
The JS inside could also be made customisable. Alternatively the string can be amended without overrides, though Select2Behavior settings.
Currently we have to do some hacking to get rid of default behavior, to add our slightly customized JS: