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

Selection callback #22

Closed
bianchimro opened this issue Feb 21, 2013 · 6 comments
Closed

Selection callback #22

bianchimro opened this issue Feb 21, 2013 · 6 comments
Assignees
Milestone

Comments

@bianchimro
Copy link

It would be nice to have a simple way to set a custom callback when a suggested item is selected.

I expect something like:

selectCallback : function(typeaheadItem, selectedItem){ .... }

where

  • typeaheadItem is the text input
  • selectedItem is the suggested item that was selected

This way it would be easier to user other properties/attributes of the selected item (not only the value property) when something is selected.

@jharding
Copy link
Contributor

I agree this would be nice. I think triggering custom events on the typeahead input is the best way to go about this. Thoughts?

@bianchimro
Copy link
Author

Sorry, i missed your point in my previous answer. (deleted it)

Yes, you are right, a custom event could be a nice implementation.
Another one could be passing the callback when activating typeahead, but the problem here is that we have per-dataset options and not global options.

@raphaelcosta
Copy link

there is any way to listen using the .on method in EventTarget?

@jharding
Copy link
Contributor

Nope, that's used for stuff internal to typeahead.js.

@raphaelcosta
Copy link

Thanks @jharding !

justindarc added a commit to justindarc/typeahead.js that referenced this issue Feb 27, 2013
…m) to dataset and also a 'selection' event that fires when an item is selected.
@Ridermansb
Copy link

+1 =)

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

4 participants