/** * Bootstrapping the starting actions for the module */ $(document).ready(function(){ let baseUrl = getbaseUrl(); let productos = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace("name"), queryTokenizer: Bloodhound.tokenizers.whitespace, remote: { 'cache': false, url: baseUrl + '/api/employee/find', replace: function(url, uriEncodedQuery) { return url + '/' + uriEncodedQuery }, wildcard: '%QUERY', filter: function (data) { return data; } } }); // Initialize the Bloodhound suggestion engine productos.initialize(); $("#editEmploySearch").typeahead({ hint: true, highlight: true, minLength: 1 }, { name: "result", displayKey: "fullName", source: productos.ttAdapter() }).bind("typeahead:selected", function(obj, datum, name) { $(this).data("id", datum.code); console.log(datum.code); }); });