[add] Bloodhoung search

This commit is contained in:
2018-08-12 21:45:50 -06:00
parent e9effb7fcc
commit 49e114c18a
4 changed files with 55 additions and 3 deletions

View File

@@ -0,0 +1,42 @@
/**
* 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);
});
});