closing select2 on click away when closeonselect is false
Asked Answered
H

0

2

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/

Hemichordate answered 24/3, 2018 at 15:46 Comment(1)
did you figure it out? I have the same problem, #52297849 One more issue: If you have several Select2's, I want to target the exact one to close, rather than hard-code ID I want to get the dropdown described by this Select2. Is that possible without a lot of jQuery selection magic?Notecase

© 2022 - 2024 — McMap. All rights reserved.