mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 23:42:32 +01:00
Fixed search showing duplicates when typing fast
Fixed search input showing duplicates when typing fast. Function from: //https://stackoverflow.com/a/1909508
This commit is contained in:
parent
40db8d4361
commit
a5bf2c5f07
13
assets/js/scripts.min.js
vendored
13
assets/js/scripts.min.js
vendored
@ -364,7 +364,16 @@ function yabsModalView(hostname, id) {
|
||||
});
|
||||
}
|
||||
|
||||
$('#searchInput').keyup(function() {
|
||||
//https://stackoverflow.com/a/1909508
|
||||
function delay(fn, ms) {
|
||||
let timer = 0
|
||||
return function(...args) {
|
||||
clearTimeout(timer)
|
||||
timer = setTimeout(fn.bind(this, ...args), ms || 0)
|
||||
}
|
||||
}
|
||||
|
||||
$('#searchInput').keyup(delay(function (e) {
|
||||
var search_term = this.value;
|
||||
$('#searchDivBody').empty();
|
||||
$.ajax({
|
||||
@ -375,4 +384,4 @@ $('#searchInput').keyup(function() {
|
||||
$('#searchDivBody').append(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, 500));
|
Loading…
Reference in New Issue
Block a user