[v2] Autocomplete searchBar - Handle On Clear event


#1

Hi Vladimir, Is there any event inside autocomplete that I can use to handle when the user clear the autocomplete?


#2

I dont know if there is a method for that. But you can try like this:

Dom7(Dom7('#autocompleteId .input-clear-button')).on('click', function(e) { alert('clear!!!')})

#3

Yes, I did that, but It would be fantastic to have it


#4

Just curious. Is there a specific reason to wrap Dom7 inside Dom7 since the return would be a Dom7 element?


#5

If you’re looking for an event to listen to based on original code, closest is to use the ‘change’ event and check for length 0. But then, it can be triggered by deleting inside as well.

Perhaps can be a feature request? Or you can edit the base js and emit a new event that you can listen to when clear is pressed


#6

sry no, i just copy and paste from the console, was testing


#7

I think that would be useful to have it as a feature.
The onchange is not fire in that case.