How to add attributes to my select option with tom-select.js #636
Marcelin97
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I defined my tom-select.js. now I do a :
tomSelect.on('type', () =>{}
inside I do a fetch request to retrieve my data. in my then I do this:
JSON.parse(data).forEach((item ) => {
const option = {
text: item.data,
value: item.value,
};
tomSelect.addOption(option);
in my data I get :
[{"value": "value", "text": "text", "id": "id", 'idtype": 'idType"}, {"value": "value2", " text": "text2", "id2": "id", 'idtype2": 'idType"}]
I would like to pass to my select the id and idType. I thought about the attribute, but I can't add its id and idtype for each select.
Beta Was this translation helpful? Give feedback.
All reactions