Created
February 7, 2013 18:00
-
-
Save pafnuty/4732828 to your computer and use it in GitHub Desktop.
searchsuggestions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Помойму лучше использовать setTimeout.. :)
И из-за чего такой костыль с Query?