문제

How can I use a textarea instead of the default text input when using select2?

I've tried changing the input tag to a textarea tag, but it seems that after the select2 js initialization is done, the element is converted to an input element.

The reason I want a textarea is because I want to signify to my users that they'll be choosing many items, so having multiple rows will be useful for my intentions.

도움이 되었습니까?

해결책

Do you need to? You can set the height using css

.select2-container, .select2-choices { height: 200px;}

Edit: or even better you can just style a class on your input before you apply .select2() to it and the container will automatically append that class to the container. You can then make it look like a textarea.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top