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

Is there a way to determine whether a comboBox was opened by click or by autosuggest?

1 Answer 288 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Carrie
Top achievements
Rank 1
Carrie asked on 06 Nov 2013, 09:24 PM
Hello,

I need to be able to determine how the change event is triggered for a combo box.  For instance if the user just entered text and the AutoComplete Suggest opened the box ...or...if the user clicked the arrow to open the box.

I need to do something different in each case.

Is there anyway to determine this ?

Thanks,
Carrie

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 07 Nov 2013, 09:38 AM
Hi Carrie,

You can use the following approach.

Note that if you must support touch devices, you may need to subscribe to touchdown instead of mousedown. Touch devices fire fake mouse events as well, but with a delay, which may be too big for your needs.


$(document).ready(function() {
 
    var combo = $("#products").kendoComboBox({
        open: function(e) {
            if (clickToOpenFlag) {
                //user clicked
                clickToOpenFlag = false;
            } else {
                //user typed
            }
        }
    });
 
    var clickToOpenFlag = false;
 
    combo.data("kendoComboBox").wrapper.find(".k-select").on("mousedown", function(e){
        clickToOpenFlag = true;
    });
 
    combo.data("kendoComboBox").input.on("focus", function(e){
        clickToOpenFlag = false;
    });
 
});


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