Ari
Ari

Reputation: 41

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.

Upvotes: 1

Views: 2664

Answers (1)

OnaBai
OnaBai

Reputation: 40887

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).

Upvotes: 1

Related Questions