Recently, I have been exploring the integration of Select2 in an older application. I have successfully converted the old dropdown into a Select2 dropdown and everything seems to be functioning properly. The dropdown is populated with options and all related functions are working as expected. However, I am now looking to implement a more advanced feature.
In the original dropdown, each option is equipped with a custom attribute:
<option onlyslave="True" ...> ...</option>
I am aiming to change the text color to red if the 'onlyslave' property is set to true. If it's false, the text should remain black. I have managed to make the text red by utilizing the following CSS code:
.select2-results {
color: red;
}
However, applying an attribute selector [onlyslave="true"] does not yield the desired outcome. Despite having 'False' and 'True' values within the options of the 'old' dropdown, the text does not turn red. Additionally, variations in capitalization such as 'Truth' or 'truth' do not affect the result.
.select2-results[onlyslave="true"] {
color: red;
}
If anyone has suggestions on how to achieve this functionality, please share your insights. I have found the Select2 documentation to be somewhat lacking in this area. My current version of Select2 is 4.0.5, but I am open to downgrading if necessary.