django-selectable
django-selectable copied to clipboard
AutoCompleteSelectWidget does not work with empty input
Hallo,
using a AutoCompleteSelect Widget, i encounter a problem when deleting a selected item.
-
Open form with field (Charfield, default='', blank=True) and save form without changing anything. The field is empty and stays empty in the database
-
Select a item with AutoCompleteSelect and save form. The item is now saved to the database.
-
Try to delete the selection. In my case, the input field shown to the user is empty, but in the send POST data the old item id is not deleted. After saving form, the item is still in database.
How is it possible to delete a item to get an empty field again?
Update:
after a click outside the input, the post data is correct. So it looks like only a js trigger does not work as expected. With allow_new there is also no problem.
Yes the hidden input is cleared with the autocomplete plugin detects a change or select even which likely requires the input losing focus.
After some research it looks like the change event is the right one for older browsers, new browsers support input to trigger all changes made by the user, for example paste.
Would be nice to have best modern browser support by django selectable.
selectable does not directly bind to the input change/select/input. It catches the events propagated from the underlying widget from jQuery UI.