Files
nairobi/app/assets/javascripts/suggest.js.coffee
Javi Martín b27855c1cf Use double quotes in CoffeeScript files
As we do in the rest of the application.

Note we cannot add a rule enforcing double quotes because CoffeeScript
Lint does not have such rule.
2019-03-06 11:41:21 +01:00

26 lines
567 B
CoffeeScript

App.Suggest =
initialize: ->
$("[data-js-suggest-result]").each ->
$this = $(this)
callback = ->
$.ajax
url: $this.data("js-url")
data: { search: $this.val() },
type: "GET",
dataType: "html"
success: (stHtml) ->
js_suggest_selector = $this.data("js-suggest")
$(js_suggest_selector).html(stHtml)
timer = null
$this.on "keyup", ->
window.clearTimeout(timer)
timer = window.setTimeout(callback, 1000)
$this.on "change", callback