Bootstrap Typeahead updater not working

NickNick picture NickNick · Oct 12, 2013 · Viewed 11.7k times · Source

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?

Answer

NickNick picture NickNick · Oct 13, 2013
$('input[name=recerv_country]').on('typeahead:selected', function(evt, item) {
    alert(item.value);
});