[add] Bloodhoung search
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user