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

2 posts, 1 answers
  1. Carrie
    Carrie avatar
    27 posts
    Member since:
    Aug 2013

    Posted 06 Nov 2013 Link to this post

    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
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 07 Nov 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top