Search code examples
autocompletekendo-uikendo-autocomplete

Setting focus() on autocomplete textbox


I am trying to set the cursor on the textbox that has been set to a kendoAutoComplete, but the cursor does not show.

Using Kendo's AutoComplete basic demo I am running the following code in the Chrome Developer console, but the cursor is not showing.

$('#countries').focus()

When the code is run, I do see that the span around the input box does get the 'k-state-focused' class which changes the border color to gray, but that's all it does.

From what I can tell, the 'k-state-focused' css class doesn't hide the cursor. So not sure if Kendo is somehow intercepting the focus in JavaScript and not setting it, or because the textbox has a span around it, the focus is being hidden.


Solution

  • Instead of $('#countries').focus() do $('#countries').data("kendoAutoComplete").focus().

    Due to Kendo UI decorations around HTML elements you should use AutoComplete focus.