In your example you don't need it since you are actually no longer using autocomplete
.
As you say, jQuery data
function attaches arbitrary data to DOM elements, that's exactly what KendoUI does when creates any Widget: any data that is needed, is attached to the DOM element associated to the widget so if in the future you need to do some operation with the widget, you can get a reference to it using data
.
Example: You create a Kendo Window
, and the user can close it (which does not mean destroy it, simply hides it). If in the future you need to open it, you simply do $("#win-id").data("kendoWindow").open()
. If you need to do many operations with that window
, instead of having to execute $("#win-id").data("kendoWindow")
each time you might do:
var myWindow = $("#win-id").data("kendoWindow");
but sometime you do it when creating it:
var myWindow = $("#win-id").kendoWindow({}).data("kendoWindow");
Which means that you create a kendoWindow
attached to a DOM element which id
is win-id
and then you get a reference to it by executing .data("kendoWindow")
on it.
In the code that you show, this is basically what they do: create an autocomplete
and get a reference to it for future use.