Search code examples
javascriptdjangodjango-autocomplete-light

How to deselect all choices of the django-autocomplete-light widget via javascript?


I need to clear an already selected value of the django-autocomplete-light widget via javascript (or may be reload the widget, if it is more simple). How can it be done?

Thanks.


Solution

  • So I have only one auto-complete widget on a page and only one item is selected.

    This code deselects the item:

    var widget = $('.autocomplete-light-widget').yourlabsWidget();
    var choice = $('span.div.hilight');
    widget.deselectChoice(choice);