Reputation: 7647
I have a situation where I need to make <s:select>
drop down value to read only.
But since the <s:select>
only has disabled property, how to make <s:select>
behave read only?
I have tried to put readonly
attribute directly on <s:select>
, but it didn't work.
Upvotes: -1
Views: 4963
Reputation: 766
You can do it Write some CSS, and then just put a HTML attribute readonly="true"
/*Select2 ReadOnly Start*/
select[readonly].select2-hidden-accessible + .select2-container {
pointer-events: none;
touch-action: none;
}
select[readonly].select2-hidden-accessible + .select2-container .select2-selection {
background: #eee;
box-shadow: none;
}
select[readonly].select2-hidden-accessible + .select2-container .select2-selection__arrow, select[readonly].select2-hidden-accessible + .select2-container .select2-selection__clear {
display: none;
}
/*Select2 ReadOnly End*/
Upvotes: 1
Reputation: 1
It looks like putting a HTML attribute contenteditable="true"
makes it to behave like readonly. That a way you couldn't select the value from dropdown.
Upvotes: 1