Fix suggestions keyup timeout.

The browser was generating one AJAX request per keystroke, ignoring the
timeout. The clearTimeout() function needs to be called with the ID
value returned by setTimeout().
This commit is contained in:
Javier Martín
2018-06-28 21:06:02 +02:00
parent cd15e3f23a
commit e655c3c958

View File

@@ -16,8 +16,10 @@ App.Suggest =
js_suggest_selector = $this.data('js-suggest')
$(js_suggest_selector).html(stHtml)
timer = null
$this.on 'keyup', ->
window.clearTimeout(callback)
window.setTimeout(callback, 1000)
window.clearTimeout(timer)
timer = window.setTimeout(callback, 1000)
$this.on 'change', callback