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

Add a Clear Method #126

Closed
jimmynotjim opened this issue Mar 23, 2013 · 8 comments
Closed

Add a Clear Method #126

jimmynotjim opened this issue Mar 23, 2013 · 8 comments

Comments

@jimmynotjim
Copy link

Any chance we could get a clear method to clear the input and typeahead's results? Using jQuery's .val(''); on the input element clears it, but when you focus typeahead adds the last entered text back in. Having a clear method would be useful to create a clear button (similar to the iOS standard search fields) for small screen touch devices where selecting and clearing inputs is a bit more tedious.

@Jellyfrog
Copy link

👍

@jharding
Copy link
Contributor

Adding something like this has been discussed in #28 – it's definitely something that'll get added at some point.

@jimmynotjim
Copy link
Author

Awesome, look forward to it and thanks for all the hard work. This is def the best autocomplete/suggestion type plugin I've used yet.

@jharding
Copy link
Contributor

jharding commented Apr 1, 2013

v0.9.1, which should go out shortly, has a jQuery#typeahead('setQuery', query) plugin method that will allow you to implement a clear method:

$('.typeahead').typeahead('setQuery', '');

@jimmynotjim
Copy link
Author

Nice, thanks again for this one

@yrshaikh
Copy link

how about a clear icon ?

@vahidmulla
Copy link

$('.typeahead').typeahead('val', myVal); worked for me

@ernstralek
Copy link

This could help, I resolved this simulating the click on cancel button

$('.typeahead__cancel-button').trigger('mousedown');

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

No branches or pull requests

6 participants