w3co / jcf

Advanced form elements customization using CSS/JS
MIT License
202 stars 55 forks source link

Scrollbar to selected option in select #38

Closed suvsv closed 7 years ago

suvsv commented 7 years ago

Thank you for your plugin. Could you please supporting. When a drop-down list in the select is opened, the scrollbar is set on the top options. Can we set scrollbar to selected option of the select (so selected option is visible in the list) programmatically?

inferpse commented 7 years ago

@suvsv You can use the same method which is used by the library itself. So something like this could work for you:

var select = $('#my-select'),
    instance = jcf.getInstance(select);

select.prop('selectedIndex', 17);
instance.showDropdown();
instance.scrollToActiveOption();
inferpse commented 7 years ago

Looks like this is not an issue. Closing it.