Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  98] [ 6]  / answers: 1 / hits: 27573  / 11 Years ago, sat, september 28, 2013, 12:00:00

How do I change the data placeholder with select2?



So far I've tried this.



$(#city).select2({placeholder:foo});


And this...



$(#city).attr(data-placeholder,bar);


But neither works.


More From » jquery

 Answers
10

I found that if I just set the attr e.g. $(#city).attr('data-placeholder', 'bar'), there is no effect. However, if I set the attr and then call $(#city).select2() with no arguments, then the placeholder updates.



e.g.



$(#city).attr(data-placeholder,bar);
$(#city).select2();

[#75372] Thursday, September 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
teagan

Total Points: 98
Total Questions: 106
Total Answers: 101

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;