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

how to get the selected item? #16438

Closed
slavugan opened this issue Mar 10, 2015 · 5 comments
Closed

how to get the selected item? #16438

slavugan opened this issue Mar 10, 2015 · 5 comments
Milestone

Comments

@slavugan
Copy link

how can I get the selected item in awesomplete-select or awesomplete-selectcomplete handler? I have complex item like

  • blabla bla@bla
  • and I need to get the selected item from list to create custom datapasting

    @LeaVerou
    Copy link
    Owner

    I think you need to take a look at replace here: http://leaverou.github.io/awesomplete/#extensibility

    (but excellent point re: the event. We need to include this as an event property)

    @matanox
    Copy link

    matanox commented Jul 27, 2015

    I think checking the underlying html element's value would be at par with using replace, but ultimately including the selection in the events may really seem to make sense...

    @vlazar vlazar added this to the v1.1 milestone Jan 31, 2016
    @vlazar
    Copy link
    Collaborator

    vlazar commented Feb 12, 2016

    @slavugan Do you want to get selected DOM element <li> or selected item data like { name: "blabla" , email: "bla@bla" }?

    @vlazar
    Copy link
    Collaborator

    vlazar commented Mar 13, 2016

    Separate label/value is landed #16866
    It is also possible to initialize list with separate label/value via <datalist> or <ul>.

    Read about different label and value at the end of Basic usage section and about new data method at the end of Extend section.

    @vlazar
    Copy link
    Collaborator

    vlazar commented Mar 13, 2016

    Selected suggestion item is available as text event property for awesomplete-highlight, awesomplete-select and awesomplete-selectcomplete events.

    Awesomplete.$.bind(input, {
      "awesomplete-selectcomplete": function(evt) {
        console.log(evt.text); // String {label: "Java", value: "Java", valueOf: function, toString: function}
      }
    });

    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

    4 participants