Last active
December 15, 2015 16:19
-
-
Save ohcibi/5288207 to your computer and use it in GitHub Desktop.
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
$ -> | |
delaySearch = null # WATCH OUT | |
updatePosts = -> | |
$.get $("#search input").attr("action"), $("#search").serialize(), null, "script" | |
false | |
startUpdatePosts = -> | |
delaySearch = setTimeout updatePosts, 3000 # YOU SEE? | |
clearUpdatePosts = -> | |
clearTimeout(delaySearch) # NOW THIS WORKS! | |
$('#search input').focus() | |
$(document).on "click", ".sorter", -> | |
$.getScript @href | |
false | |
$(document).on "click", "#reset_search", -> | |
$('#search').val('') | |
$('#search input').focus() | |
$.getScript @href | |
false | |
$('#search').submit -> | |
clearUpdatePosts() | |
startUpdatePosts() | |
$("#search").keyup -> | |
clearUpdatePosts() | |
startUpdatePosts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment