5

Yeah we can add placeholder to select2 like this,

$("#e2_2").select2({
placeholder: "Select a State"
});

But I need something like this, enter image description here

Here you can see linkedin provides "Type another area of expertise". Means when you select expertise again it show placeholder for selection. I want to do same thing using select2.

Please help.

Ashwini
  • 2,449
  • 2
  • 29
  • 42
  • Hi. Have you try: $("#select2id").attr("placeholder","whatever") – JSG33kC0d3 Feb 14 '14 at 06:42
  • hey dude. check this, hope it help you. http://stackoverflow.com/a/17603167/3069595 – JSG33kC0d3 Feb 14 '14 at 08:18
  • before reading the question @JSG33kC0d3 linked to, I was going to suggest adding an option with an empty value, e.g. ``. I'm not sure if that will work with the tag option but that's how select2 normally shows the placeholder set in the initialisation when used 'normally'. – martincarlin87 May 12 '15 at 09:12

1 Answers1

0

I think it's isn't a feature of this plugin. The placeholder is "placed" only in first input field. When you "save" the first element the plugin generate a static html with a new field without any placeholder. I think to change this behavior you need to change the plugin source code.

You can find the "template" of second input inside the file:

[root]/select2-4.0.0/src/js/select2/dropdown/search.js

Frogmouth
  • 1,808
  • 1
  • 14
  • 22