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

Depending on selector used to create typeahead, using the same selector to retrieve the value may fail #815

Closed
hhamilto opened this issue Apr 3, 2014 · 3 comments

Comments

@hhamilto
Copy link

hhamilto commented Apr 3, 2014

Regarding grabbing the value back out of a typeahead:
The example in the documentation gives you the idea that you can retrieve the value by simply calling .typahead('val') on a jquery object created using the same selector as the selector used to create the typeahead. the example in the docs here:
https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md#jquerytypeaheadval
is:

var myVal = $('.typeahead').typeahead('val');

I interpreted this to mean that If I had a particular <input> with the class .typeahead on it, and I did a $('.typeahead').typeahead(... to create a typeahead on it, then the above code would hand me back the value. This isn't the case, because there is the "hint" typeahead that is copied, which doesn't have the value attached to it. You can see my problem illustrated here: http://jsfiddle.net/734x5/

I like the idea of typeahead going through the set of matched jquery elements until it finds one that has a value, and this doesn't seem too dangerous because we should know the structure of the dom nodes the plugin creates.

Modifying the documentation would be the easier choice of course :)

@jharding
Copy link
Contributor

jharding commented Apr 5, 2014

I like the idea of typeahead going through the set of matched jquery elements until it finds one that has a value, and this doesn't seem too dangerous because we should know the structure of the dom nodes the plugin creates.

I agree, this is how it should work. I'll get this fixed for the next release.

@jharding
Copy link
Contributor

jharding commented Jul 8, 2014

Fixed for v0.10.3.

@Baso1st
Copy link

Baso1st commented Jun 7, 2017

The issue still exist v 0.11.1

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

No branches or pull requests

3 participants