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

autocomplete: Get selected value on click #1615

Closed
thomas-schiller opened this issue Sep 2, 2020 · 2 comments
Closed

autocomplete: Get selected value on click #1615

thomas-schiller opened this issue Sep 2, 2020 · 2 comments

Comments

@thomas-schiller
Copy link

Hey,
is there any way to access the selected value after the autocomplete value was selected (clicked or via keyboard-navigation)?

olton added a commit that referenced this issue Sep 11, 2020
…th an attribute `data-on-autocomplete-select`. The event receives a one argument - selected value., issu #1615
@olton
Copy link
Owner

olton commented Sep 11, 2020

Currently, you can use the change event

$(input).on(Metro.events.change, function(){
    console.log(this.value);
})

In 4.4.0, you can use event onAutocompleteSelect

<input id="autocomplete" type="text" data-role="input" data-autocomplete="Ukraine, USA, Canada, Marokko, Singapur">

<script>
    $("#autocomplete").on("autocomplete-select", function(e){
        console.log(e.detail.value);
    })
</script>

@olton olton added this to the 4.4.0 milestone Sep 11, 2020
@thomas-schiller
Copy link
Author

Thanks for adding it to v 4.4.0 as well as your help!

@olton olton closed this as completed Sep 28, 2020
olton added a commit that referenced this issue Oct 28, 2023
…th an attribute `data-on-autocomplete-select`. The event receives a one argument - selected value., issu #1615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants