select2: Can't type in Select2 dropdown input search field
Can’t type in Select2 dropdown input search field.
I have found many issues listed which mentions the same problem but nothing worked for me (https://www.google.com/search?q=can’t+type+in+select2&ie=utf-8&oe=utf-8&client=firefox-b-ab). I can’t type in Select2 dropdown input search field in model dialog using jQuery. By the way i can select value fine from dropdown. Tried inserting tabindex: 0 but no luck.
$.ajax({
type: "POST",
url: "<?php echo $myScripts; ?>",
data: { id1: "get-release-dropdown-html", id100: "<?php echo $dbTable; ?>" },
success:function(releaseDropdown){
$('#progress').hide();
$( "#modelDialog1" ).dialog({
modal: true,
width: '570',
height: '600',
resizable: true,
position:
{
my: "center",
at: "center",
of: window,
},
title: "Trigger Build",
open: function() {
$(this).html("<br/>Please select job options.<br/><br/><br/><b>Release:</b>" + releaseDropdown + "<div style='margin-top:30px;'/><b>Build Release Candidate:</b><select id='sReleaseCandidate'><option value='ga' selected>GA</option><option value='beta1'>BETAX</option>'></br>");
$("#sDescription").focus();
$("#sRelease, #sReleaseCandidate").select2({
tags: true
});
},
close: function() {
$( this ).dialog( "close" );
},
});
}
});
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 22 (3 by maintainers)
Is the problem releated to #4871?
You could try to define the parameter “DropdownParent” of the select2 element. The name given to the parameter is the name of the modal form where the select2 is placed on. Here below an example of how to use this parameter.
remove “tabindex” attribute from modal
Have you tried setting
dropdownParent? See https://select2.org/troubleshooting/common-problems#select2-does-not-function-properly-when-i-use-it-inside-a-bootstGood catch 😃 Issue is fixed, here is the solution. No need to write in document.ready, mention inside jquery modal dialog code:
removing “tabindex” from #mymodal solves the problem…
@ProgrammingTestGitHub It works. Thanks
Tried this code but no luck:
thank you so much, it solve my proplem.
I was about to go nuts until I came across this solution posted above :
$(document).ready(function() { $("#select2insidemodal").select2({ dropdownParent: $("#myModal") });});I am transitioning my site to Bootstrap 4 (from 3) and my old tricks for select2 in modals were not working. It was deja vu all over again. This actually worked for me!
a working example,
That worked. But why?