Lets say I have item1,item2,item3 pre selected, how do i allow the user to delete only item3 and hide the X delete button from the others.
Thanks in advance
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
Not the best approach because I should not rely on the option label since it may not be unique but this is the only solution I got.
Let's say I have a select like this
and you want the selected values to be unclearable, u can achieve this with this simple code:
u can also use the data-unclearable attribute for example on the options u want do not want them to be clearable, and check if the attribute is there.
You can have a property(say canDelete – which should be populated before you render the items in UI) for the items which will identify if a particular item can be deleted or not and based on the flag you can show or hide the "X" button.
Also if you can share the code which you have tried, it would be easier to understand your question.