Skip to content

Instantly share code, notes, and snippets.

@pafnuty
Created February 7, 2013 18:00
Show Gist options
  • Save pafnuty/4732828 to your computer and use it in GitHub Desktop.
Save pafnuty/4732828 to your computer and use it in GitHub Desktop.
searchsuggestions
function FastSearch() {
$("#story").attr("autocomplete", "off");
$("#story").blur(function () {
$("#searchsuggestions").fadeOut()
});
$("#story").keyup(function () {
var a = $(this).val();
if (a.length == 0) $("#searchsuggestions").fadeOut();
else if (dle_search_value != a && a.length > 3) {
clearInterval(dle_search_delay);
dle_search_delay = setInterval(function () {
dle_do_search(a)
}, 1000)
}
})
}
function dle_do_search(a) {
clearInterval(dle_search_delay);
$("#searchsuggestions").remove();
$("body").append("<div id='searchsuggestions' style='display:none'></div>");
$.post(dle_root + "engine/ajax/search.php", {
query: "" + a + ""
}, function (b) {
$("#searchsuggestions").html(b).fadeIn().css({
position: "absolute",
top: 0,
left: 0,
zIndex: "9999"
}).position({
my: "left top",
at: "left bottom",
of: ".text-input",
collision: "none"
})
});
dle_search_value = a
}
@rolife
Copy link

rolife commented Feb 10, 2013

Помойму лучше использовать setTimeout.. :)
И из-за чего такой костыль с Query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment