Unable to Retrieve Data from Hidden jQuery AutoComplete

1 Answer 21 Views
AutoComplete Data Source
Carlos Arturo
Top achievements
Rank 1
Carlos Arturo asked on 22 Mar 2025, 05:53 AM
Hello,

I'm trying to retrieve data from the kendoAutoComplete component, but I'm encountering an issue when the input is hidden.

The happy path works perfectly when the input is visible. For example:

<input id="test">

var data = ["One", "Two"];
$("#test1").kendoAutoComplete({
  dataSource: data
});

$("#test1").data('kendoAutoComplete').dataSource.data() // return  ["One", "Two"]

However, the problem arises when the input is not visible (e.g., using style="display: none;"). I use the same code, but when I call the data() method, it does not return the original data. Instead, it returns undefined until I make the input visible again and reload the data source. Only then does it start working correctly.

Example:

<input id="test" style="display: none;>

var data = ["One", "Two"];
$("#test1").kendoAutoComplete({
  dataSource: data
});

$("#test1").data('kendoAutoComplete').dataSource.data() // return  "undefined"

Is there a workaround or specific configuration to ensure the data() method behaves as expected, even when the input is hidden?

Thank you in advance for your assistance!

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 26 Mar 2025, 02:32 PM

Hello, Carlos,

I tested the provided code, and the data method doesn't return the data regardless whether the component is visible or not. The reason is that the AutoComplete doesn't automatically bind to the data. You need to call the dataSource fetch method first before calling the data method. Here's a small example for reference.

Let me know how that works for you.

Regards,
Martin
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
AutoComplete Data Source
Asked by
Carlos Arturo
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or