Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement select2 with lock selection?

I am trying to use select2 with one disabled value.

I am trying to implement it like

$('#select_currency').select2('data', preloaded_data);

I have been reading about Lock selections but I am not able to implement it, could you please someone let me know how to implement it or is there any tutorial about it.

like image 590
Nishikant Avatar asked May 15 '13 11:05

Nishikant


1 Answers

You can easely add locked="locked" if you use v3.5 http://select2.github.io/select2/#locked-selections.

But in v.4.x this functionality is removed.

I've found solution (or hack:) ) for v.4.x, a little bit dirty with error in console, but it works. Anyway it is best solution what I've found. Check my jsfiddle:

https://jsfiddle.net/o3s3y42e/4/

like image 155
Roman Yakoviv Avatar answered Dec 08 '22 22:12

Roman Yakoviv