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

[typeahead.js] data-* attributes #7957

Closed
krisrybak opened this issue May 22, 2013 · 2 comments
Closed

[typeahead.js] data-* attributes #7957

krisrybak opened this issue May 22, 2013 · 2 comments

Comments

@krisrybak
Copy link

Since typeahead imitates behaviour of dropdown (selecting item from the list) it is very likely that users would like to pass a some sort of value when item is selected (this would normally be some sort of id). At the moment typeahead renders a list and the only value you can access without hacking is the .text of

  • element:

    var stateList = ["California", "Arizona", "Nevada"];
    //..
    <ul>
       <li data-value="California">
           <a href="#">California</a>
       </li>
    </ul>

    It would be a nice addition if we were able to pass some sort of id. In fact as many as you may require:

    var stateList = [
        {"stateCode": "CA", "value": "California", "data_attr":{"id":"1", "state-code":"CA"}},
        {"stateCode": "AZ", "value": "Arizona", "data_attr":{"id":"2", "state-code":"AZ"}},
        {"stateCode": "NV", "value": "Nevada", "data_attr":{"id":"3", "state-code":"NV"}}
       ...
    ]
    //..
    <ul>
       <li data-value="California" data-id="1" data-state-code="CA">
           <a href="#">California</a>
       </li>
    </ul>
  • @cvrebert
    Copy link
    Collaborator

    Moot due to #7805.

    @cvrebert
    Copy link
    Collaborator

    You may want to try Select2.

    @mdo mdo closed this as completed May 22, 2013
    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

    3 participants