4

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?

tonytonov
  • 25,060
  • 16
  • 82
  • 98
user2901948
  • 43
  • 1
  • 3

3 Answers3

4

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.

Kulgar
  • 1,855
  • 19
  • 26
  • The "allowClear option allows the user to remove selections. The question is about disabling remove icon, to disallow the user from removing tags. – Indrajeet Mar 06 '18 at 18:24
  • The link you are posting is dead. This is an updated link: https://select2.org/selections#clearable-selections – joker Jul 02 '18 at 14:31
  • Any news about this ? I am also looking for this functionality. – hathija Nov 08 '18 at 11:46
  • 1
    @hathija : updated my answer. You should be good to go with that. Let me know if you don't. – Kulgar Nov 12 '18 at 17:43
0

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.

Community
  • 1
  • 1
Milan Stojanovic
  • 307
  • 1
  • 14
0

This is also works

span.select2-selection__clear {
    display: none;
}
RISHIKESH PAL
  • 226
  • 2
  • 7