This is a migrated thread and some comments may be shown as answers.

Trouble filling in input field with text on tab

1 Answer 251 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 16 Mar 2015, 03:24 PM
I'm trying to use a "tab" to grab the currently highlighted item in the dropdown and populate it into the the text field. However, I'm having 2 separate problems with this.

The first is that I cannot get the "tab" key's default action to stop from firing. I have tried capturing the keydown even from my MultiSelect box's input field using the following code:

$("#myInput").data().kendoMultiSelect.input.on("keydown",function(event) {
        var code = event.keyCode;
 
        if (code == 9) { //9 is the keyCode for Tab
            event.preventDefault();
        }
}

Using this code, the focus is still moved from the input to the next item on the page and is not giving me the desired functionality of doing nothing when tab is pressed.

My next problem is the fact that I cannot find how kendo determines which item in the list of filtered items is highlighted. I don't see any properties being set when you use the arrow keys to highlight the input you want from that list. I would like to get the displayed text inside that highlighted item and populate it into the text input area when I press tab. Currently I cannot figure out how to figure out how to get the item without selecting it with a click or hitting enter while it is highlighted.

Help with either or both of these would be extremely appreciated.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 18 Mar 2015, 08:22 PM
Hello Peter,

wiring the keydown event is the correct way to go. You will need, however, to prevent the default behavior and stop event propagation. Here is a Dojo demo that demonstrates this approach. It also uses the current method to get the active element. 

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
MultiSelect
Asked by
Peter
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or