Clear autocomplete value on select change event

1 Answer 1965 Views
AutoComplete
Richard Wilde
Top achievements
Rank 1
Richard Wilde asked on 27 Nov 2012, 12:18 PM
I have the following jsFiddle and want to clear the autocomplete field when the user has selected an item. The following code does not do this:-

$("#input").data("kendoAutoComplete").value("");
 

Is this possible?

//create AutoComplete UI component
$("#input").kendoAutoComplete({
    dataSource: data,
    filter: "startswith",
    placeholder: "Select country...",
    select: function(e) {
        var dataItem = this.dataItem(e.item.index());
        $('#list').append("<li>" + dataItem + "</li>");
        $("#input").data("kendoAutoComplete").value(""); 
    }
});

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 29 Nov 2012, 10:12 AM
Hello Richard,

 
If you need to clear the autocomplete value in the select event, then you will need to prevent it:

select: function(e) {
        var dataItem = this.dataItem(e.item.index());
        $('#list').append("<li>" + dataItem + "</li>");
        $("#input").data("kendoAutoComplete").value("");
        e.preventDefault();
}

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
Richard Wilde
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or