Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to clear the "listbox" in the dom? #17157

Open
ElieMouawad opened this issue Sep 5, 2018 · 3 comments
Open

Is there any way to clear the "listbox" in the dom? #17157

ElieMouawad opened this issue Sep 5, 2018 · 3 comments

Comments

@ElieMouawad
Copy link

ElieMouawad commented Sep 5, 2018

Hello, I'm using the library and I was wondering if there's anyway to clear out the Listbox in the dom that has the list of li/ul results? I want to be able to clear it once I pick a suggestion from the dropdown or when im doing a new search.

The reason for this request is sometimes for fast typers OR users that would select all and start typing, they would get a glimpse of the old suggestions in the drop down before it overwrites itself with the new suggestions. Also I'm having a rare bug where sometimes for some reason I'm not sure of yet (I can't reproduce it constantly) two dropdowns overlap, 1 having an old suggestion that is stuck there and the new suggestions in a dropdown below the first one. Maybe if I'm able to destroy the whole listbox of li and it's elements, I would eliminate those problems most probably.

I tried to add an on.('input') even that gets the text and checks if the length is <= 1, I select $("role=listbox") by JQuery and call empty: $("role=listbox").empty(), which doesn't seem to do it for me as I still get glimpses of the old suggestions before destruction.

It's driving me crazy and I thought maybe someone here would be able to help with a clean and consistent way that I'm not aware of.

I'm getting my suggestion list from an ajax call so everytime I wait like 150 ms for user input then trigger the call which would get me all the needed values and set them in the awesomplete.list. So before this 150 ms is done waiting, the box would be displaying the old suggestions.

@LeaVerou
Copy link
Owner

LeaVerou commented Sep 5, 2018

Any chance you could record a quick video of the behavior you're trying to avoid? Sounds like it may be related to transitions on the listbox. If you set transition: none on it temporarily (via .css() since you're using jQuery), that might help.

@ElieMouawad
Copy link
Author

Hello Lea,

Transition is already set to none as that helped us make the control I'm building way more responsive.
This is a link of the video that shows what I described in my post above.

https://vimeo.com/288698483

Note that on keyup event I'm trying to do: $('#awesomplete_list_1').empty(); just to clear the available options maybe that would help, and that's triggering, still you get a glimpse of the previous options as you start writing and I have absolutely no idea where's it's bringing them from, as I inspected the dom to see if there's still any residue.

Also note that i'm using the keyup event to trigger an timeout so the control would actually wait the user for 150 ms to give a buffer for fast typers to finish their word before going to the API I'm calling to bring suggestions.

@LeaVerou
Copy link
Owner

LeaVerou commented Mar 1, 2019

I have been struggling with that too. Author, you are a dumb cunt for making your addon not work with dynamic Ajax values. I've lost 2 hours because of your stupid code.

@rsanjar LOL, feel free to return it and get your money back. 😂 And GTFO, rude assholes are not welcome here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants