I want to run Javascript function just after user select a value using twitter bootstrap Typeahead.
I search about some thing like selected event.
I want to run Javascript function just after user select a value using twitter bootstrap Typeahead.
I search about some thing like selected event.
According to their documentation, the proper way of handling
selected
event is by using this event handler:For an explanation of the way typeahead works for what you want to do here, taking the following code example:
HTML input field:
JavaScript code block:
Explanation:
$('#my-input-field').typeahead(
source:
option to fetch the JSON list and display it to the user.updater:
option. Note that it hasn't yet updated the text field with the selected value.item
variable and do what you want with it, e.g.myOwnFunction(item)
.$fld
, in case you want to do something with it. Note that you can't reference the field using $(this).return item;
within theupdater:
option so the input field is actually updated with theitem
variable.first time i've posted an answer on here (plenty of times I've found an answer here though), so here's my contribution, hope it helps. You should be able to detect a change - try this:
I created an extension that includes that feature.
https://github.com/tcrosen/twitter-bootstrap-typeahead