Adapt suggest script for translations

Proposal, Debate, Budget Investment  and Comment will be translatable
models soon. This commit prepares suggestions script to work well with
translatable forms elements too.
This commit is contained in:
Senén Rodero Rodríguez
2019-01-12 14:23:00 +01:00
committed by voodoorai2000
parent 4f0d1399f2
commit cf370cab84

View File

@@ -9,11 +9,15 @@ App.Suggest =
callback = ->
$.ajax
url: $this.data("js-url")
data: { search: $this.val() },
type: "GET",
data:
search: $this.val()
type: "GET"
dataType: "html"
success: (stHtml) ->
js_suggest_selector = $this.data("js-suggest")
if js_suggest_selector.startsWith(".")
locale = $this.closest(".translatable-fields").data("locale")
js_suggest_selector += "[data-locale=#{locale}]"
$(js_suggest_selector).html(stHtml)
timer = null