country-select-js icon indicating copy to clipboard operation
country-select-js copied to clipboard

How to make country-select-js readonly?

Open p770820 opened this issue 1 year ago • 1 comments

I would like to know how to make the country-select-js library readonly. Currently, I'm using the library for a country selection feature, but I want to prevent users from modifying the selected country. Is there a way to achieve this functionality with country-select-js? I would appreciate any guidance or code examples on how to implement the readonly behavior.

The solution I have currently

    var element = document.querySelector(".country-list.hide");
    element.remove();

p770820 avatar Jul 12 '23 08:07 p770820

Not sure if that helps here, but I use the readonly attribute on the input field and style the background with the :read-only pseudo-class.

I haven't figured out, however, how to open the menu. Just removing the "hide" class doesn't add the event listeners to the menu items. Triggering a click event on the .selected-flag div opens it for a short time and closes it immediately.

genseirin avatar Oct 19 '23 13:10 genseirin