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

catch keyup or keydown event for dropdownlist

3 Answers 539 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
yaron
Top achievements
Rank 1
yaron asked on 05 Nov 2012, 09:04 AM
Hi,
I use dropdownlist ,and i want to catch the event when user changes his selection
When I use the mouse,I succeed to catch the "change" event,but when i use the keyboard ,the "change" event does not fire (the auto complete of the dropdown works),How can I catch this event or any other event for changing dropdown selection with keyboard
?
I attached my code below.
Thanks in advance.



html code:
 <input id="identificationTypes" name="identificationTypes" requiredidtype />

script code:

  $("#identificationTypes").kendoDropDownList({
            index: 0,
            optionLabel: "-------please choose------",
            dataTextField: "Value",
            dataValueField: "Key",
            filter: "contains",
            change: onChange,
            dataSource: {
                type: "json",
                pageSize: 20,
                transport: {
                    read: "../ContactDetails/GetIdentificationTypes"
                }
            }
        });

function onChange() {
alert('bla');
}

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 08 Nov 2012, 09:13 AM
Hello Yaron,

Basically the change event is triggered when you "blur" (loose focus) or press "enter".

As a work-around you could attach a handler to the keydown event like this one:
$('#DropDownID').closest('.k-dropdown.k-widget').keydown(function(e){
    var theValue = $('#DropDownID').data().kendoDropDownList.value();
   console.log(theValue );
})

I hope this helps.

Kind regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Lasse
Top achievements
Rank 1
answered on 02 Jun 2015, 10:07 AM

Is this still the case? Is there no other way to trigger the change event when the value is changed using the keyboard.

Seems a little weird to fire onchange event only on blur...

0
Kiril Nikolov
Telerik team
answered on 05 Jun 2015, 06:18 AM
Hi Mikkel,

Te change event is triggered when you "blur" (loose focus) or press "enter". So if you want to trigger it in any other circumstance you will need to do it manually.

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
DropDownList
Asked by
yaron
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Lasse
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or