简体   繁体   中英

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.

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);

I have a widget that only allows 1 item to be selected so I used this code to reset the field and run the deselectChoice event.

var widget = $('.autocomplete-light-widget').yourlabsWidget();
widget.freeDeck()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM