select2-jquery: How to set maximumselectionsize dynamically

[亡魂溺海] 提交于 2019-12-11 00:08:54

问题


I've a requirement where I'll decide Max selections to be allowed in select2 ui.How can I do that. I tried by

$('#ChnageLnk').on('click',function(){
$('#SelectD').select2({maximumselectionsize :1});
});

回答1:


Edit

Sorry - just checked. The option should not be all lowercase - it should be camel case like so:

$('#ChnageLnk').on('click',function(){
   $('#SelectD').select2({ maximumSelectionSize: 1 });
});

Fiddle here.




回答2:


Please, note that since version 4.0 of select2 they have changed maximumSelectionSize to maximumSelectionLength.

You can find more in this question: maximumSelectionSize isn't working in Select2




回答3:


$('#ChnageLnk').on('click',function(){ $('#SelectD').select2({ maximumSelectionSize: 1 }); });



来源:https://stackoverflow.com/questions/18855107/select2-jquery-how-to-set-maximumselectionsize-dynamically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!