How do I change the name that displays in pillbox>


#1

Hello,

I’m a newbie in Select2. I’m applying it for the drop down list that can perform multiple select. I wonder is there anyway to change the name of the selected item that displays in pillbox?
For example:
I have a list of country:

  • United State
  • Canada
  • New Zealand
    Currently, when we select United State, the pillbox will display the whole name as “United State”. But can it display the shorter name that we customize such as “US” or “CA” or “NZ”?

#2

There are two approaches, either of which should work. You can supply your own createTag function to return whatever text you’d like, or you can supply your own templateSelection function. Either one gives you the opportunity to alter the text that is displayed in the selected item (or pillbox, in your case).