Bootstrap Typeahead updater not working
11,782
Solution 1
$('input[name=recerv_country]').on('typeahead:selected', function(evt, item) {
alert(item.value);
});
Solution 2
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
Author by
NickNick
Updated on June 12, 2022Comments
-
NickNick almost 2 years
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?