Skip to content

Instantly share code, notes, and snippets.

@ohcibi
Last active December 15, 2015 16:19
Show Gist options
  • Save ohcibi/5288207 to your computer and use it in GitHub Desktop.
Save ohcibi/5288207 to your computer and use it in GitHub Desktop.
$ ->
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