closing select2 on click away when closeonselect is false

房东的猫 提交于 2019-12-13 16:14:45

问题


is there a better way to close select2 when you click away? I have it closing with

$(document).click(function(event) { 
    if(!$(event.target).hasClass("select2-selection__rendered") &&
       !$(event.target).hasClass("select2-results__option")) {
        $("#e1").select2('close');
    }        
});

but that seems weird.

here is the fiddle http://jsfiddle.net/jEADR/5557/

来源:https://stackoverflow.com/questions/49466671/closing-select2-on-click-away-when-closeonselect-is-false

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