mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Replace typeahead, working registrar selection
This commit is contained in:
parent
c24c8c7181
commit
13349a6bc9
9 changed files with 79 additions and 23 deletions
|
@ -1,19 +1,20 @@
|
|||
$(".js-registrars-typeahead").typeahead
|
||||
source: (query, process) ->
|
||||
$.get "/admin/registrars/search", {query: query}, (data) ->
|
||||
map = {}
|
||||
registrars = []
|
||||
registrarSource = new Bloodhound(
|
||||
datumTokenizer: (d) ->
|
||||
Bloodhound.tokenizers.whitespace d.display_key
|
||||
|
||||
$.each data, (i, registrar) ->
|
||||
map[registrar.id] = registrar
|
||||
registrars.push registrar.display
|
||||
|
||||
process registrars
|
||||
updater: (item) ->
|
||||
$('input[name="domain[registrar_id]"]').val()
|
||||
|
||||
$(".js-contacts-typeahead").typeahead
|
||||
source: (query, process) ->
|
||||
$.get "/admin/contacts/search", {query: query}, (data) ->
|
||||
process data
|
||||
queryTokenizer: Bloodhound.tokenizers.whitespace
|
||||
remote: "/admin/registrars/search?q=%QUERY"
|
||||
)
|
||||
|
||||
registrarSource.initialize()
|
||||
$(".js-registrars-typeahead").typeahead(
|
||||
highlight: true,
|
||||
hint: false
|
||||
,
|
||||
displayKey: "display_key"
|
||||
source: registrarSource.ttAdapter()
|
||||
).on('typeahead:selected', (e, obj) ->
|
||||
$('input[name="domain[registrar_id]"]').val obj.id
|
||||
$('.js-registrar-selected').removeClass('hidden')
|
||||
$('.js-registrar-unselected').addClass('hidden')
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#= require bootstrap-sprockets
|
||||
#= require nprogress
|
||||
#= require nprogress-turbolinks
|
||||
#= require bootstrap3-typeahead.min
|
||||
#= require typeahead.bundle.min
|
||||
#= require_tree .
|
||||
|
||||
NProgress.configure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue