I posted this on Stackoverflow as well but thought I would post here as well.
I am trying to see if there is a way to have Select2 search a data-attr as well as the value instead of the option text alone.
For example - state drop menu has state abbreviations. Easy to search “ND” and the select menu filters to ND. However if the user types in Dakota in the search field, then both ND and SD would appear. In some cases, the search terms may be multiple items like “North America” or “Mid West” and the states tagged that can also appear.
<select id="state"> <option data-search-term="North Dakota, Mid West, Region 1" value="ND">ND</option> <option data-search-term="South Dakota, Mid West" value="SD">SD</option> </select>
This example is very simple and I am not using a states drop menu, just easier to explain it this way. Any feed back would be greatly appreciated. I tried working with the matcher aspect shown but couldn’t figure it out.