jquery select2 howto make dont close after select
Asked Answered
L

2

24
  1. When using "Multi-Value Select Boxes" http://ivaynberg.github.io/select2/ slect box drop back after each selection. Is there the way not to do it, so user can select few of it without extra click to select box?

  2. Also interested in group options. In demo url above, "Pasific Time Zone", "Mountain Time Zone" not clickable. How to make it clickable and autoselect child items?

Labionasal answered 16/10, 2014 at 2:5 Comment(0)
N
50

Question 1:

From the documentation I can see this option:

closeOnSelect: false

This option is set to true by default, meaning the select box closes on select.

So, this is a simple call of the plugin:

$('#mySelect').select2({
    closeOnSelect: false
});

Question 2:

This question is a bit vague. It's a fairly simple task, but without going through the plugin's files and understanding its logic, it's difficult to know how to answer — and I'm not spending hours trying. This is something you'll have to try yourself, as I personally don't think you'll find anyone here willing to do that for free. It's asking a little bit much.

Take a look at its files and see if you can work out what is going on and try something. People will always be willing to help if you've tried. Good luck.

Norwich answered 16/10, 2014 at 2:28 Comment(2)
thanks a lot. about q2 - I understand this, thougt there is an easy way.Labionasal
What a BUG, i can't believe, when you set the closeOnSelect: false and if max selected options are limited then you can select more than that limit.Glaudia
A
0

Working for me

$('.select2').each(function() { 
     $(this).select2({ 
        dropdownParent: $(this).parent(),
        closeOnSelect: false
     });
});
Antigua answered 20/5, 2023 at 1:55 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Gallican
Hello, please don't just submit code in your answer(s), add some details as to why you think this is the optimal solutionLiteracy

© 2022 - 2024 — McMap. All rights reserved.