Feature Input select2

PHOTO EMBED

Fri Nov 11 2022 03:39:04 GMT+0000 (UTC)

Saved by @GodFather #javascript

//Feature Input select2
(function ($) {

    var Defaults = $.fn.select2.amd.require('select2/defaults');

    $.extend(Defaults.defaults, {
        searchInputPlaceholder: ''
    });

    var SearchDropdown = $.fn.select2.amd.require('select2/dropdown/search');

    var _renderSearchDropdown = SearchDropdown.prototype.render;

    SearchDropdown.prototype.render = function (decorated) {

        // invoke parent method
        var $rendered = _renderSearchDropdown.apply(this, Array.prototype.slice.apply(arguments));

        this.$search.attr('placeholder', this.options.get('searchInputPlaceholder'));
        $(document).on('select2:open', (e) => {
            var id = e.target.id
            document.querySelector('.select2-search__field[aria-controls=select2-' + id + '-results').focus();
        });

        return $rendered;
    };

})(window.jQuery);
//End Feature Input select2
content_copyCOPY