I try this:
$('input[name=recerv_country]').typeahead({
remote : {
url: '?country=%QUERY',
filter: function(data) {
var resultList = data.map(function (item) {
return item.name;
});
return resultList;
}
},
updater : function (item) {
//item = selected item
//do your stuff.
alert(item.name);
alert('foo');
alert('bar');
//dont forget to return the item to reflect them into input
return item;
}
});
Nothing happens, alerts not appears. What I do wrong?
$('input[name=recerv_country]').on('typeahead:selected', function(evt, item) {
alert(item.value);
});
With Twitter Bootstrap 3 the Typeahead plugin has been dropped. Bootstrap recommend to use https://github.com/twitter/typeahead.js in stead. You seem to use typeahead.js cause you use the remote call. Typeahead.js hasn't a updater function.
Check the custom events section of https://github.com/twitter/typeahead.js. typeahead:selected
will fit your needs maybe.
See also: Bootstrap 3 typeahead.js, use similar functions from Bootstrap 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With