Question

Is there a way to disable the icons in ui-select2? I am using ui-select2 in angular js, which is like adding tags while posting a question on stackoverflow:

enter image description here

How can I disable remove icon conditionally?

Was it helpful?

Solution

Official website of ui select2

[Edit 2018-11-12] You could always do a "display: none" on the x span:

span.select2-selection__choice__remove {
  display: none;
}

You could also use that to disable click on it with pure JS.

And there is also a "locked" option: http://select2.github.io/select2/#locked-selections You can then control, per data, which one can't be removed from the selection.

OTHER TIPS

Could something like this help you? Remove span tag in string using jquery

It's not a direct answer, and it's not ui-select2 specific, but it should help you understand how to remove certain elements. You can just add a condition and that's that.

This is also works

span.select2-selection__clear {
    display: none;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top