I have a forum in which I change the functionality of the input tab. When the user clicks, enter the following input field to get focus and somehow iImanage to open the select2 select window on the focusin event to open the select 2 window.
But, when I select a value and press enter in the selec2 selection window, it does not close and remains open when I enter a keypress event, but it closes. When I change the key input event to any keypress event than select2, we come close and work fine, but I have to do this by typing.
What I want:
When the user selects a value in the select2 selection field and presses the enter key, he approaches and the focus moves to the next input field or any field.
What have i done so far.
$('.search-select').on("focusin",function(event) { $('#s2id_form-field-select-3').select2('open'); event.preventDefault(); });
Select2 with invalid input event
$('.select2-input').on("keypress", function(e) { if (e.keyCode == 13) { $("#select2-drop-mask").click(); $('#name').focus(); e.preventDefault(); } });
Select 2 with any keystroke.
$('.select2-input').on("keypress", function(event) { $("#select2-drop-mask").click(); $('#name').focus(); event.preventDefault(); });
Markup
<select id="form-field-select-3" name="register_id" class="form-control search-select" required="required"> <option value=""> </option> <? $query=$this->dba->get_dropdown('register',array('id','name')); foreach($query as $key=>$value): ?> <option value="<?=$key?>"><?=$value; ?></option>} <? endforeach;?> </select>
Sorry for the errors in advance, this is my first time using Select2.