Clear autocomplete value on select change event

2 posts, 0 answers
  1. Richard Wilde
    Richard  Wilde avatar
    14 posts
    Member since:
    Jul 2009

    Posted 27 Nov 2012 Link to this post

    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(""); 
        }
    });

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 29 Nov 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
Back to Top