简体   繁体   中英

How to remove focus from Kendo UI AutoComplete when an Item is selected and set focus on an input element?

I am trying to shift focus from a Kendo UI AutoComplete to an input element after an item has been selected. I've tried this...

select: function (e) {
    e.preventDefault();
    var dataItem = this.dataItem(e.item.index());
    vm.selectedProductID(dataItem.ProdID);
    $('#itemQtyBox').focus();
}

But it didn't work.

Seems that you cannot change focus from inside select handler... maybe it's acceptable for you wait a little and then do it. I mean:

select    : function (e) {
    setTimeout(function () {
        $("#itemQtyBox").focus();
    }, 100);
}

What I do is set a timeout (in the previous example 0.1 seconds) and then change focus (I know that it is not nice but works).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM