Bind typehead to contact too

This commit is contained in:
Martin Lensment 2014-09-09 13:36:28 +03:00
parent 13349a6bc9
commit 1c165cd1e4
7 changed files with 55 additions and 30 deletions

View file

@ -1,20 +1,9 @@
registrarSource = new Bloodhound(
datumTokenizer: (d) ->
Bloodhound.tokenizers.whitespace d.display_key
Autocomplete.bindTypeahead
remote: '/admin/registrars/search'
selector: '.js-registrar-typeahead'
hiddenSelector: '.js-registrar-id'
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')
)
Autocomplete.bindTypeahead
remote: '/admin/contacts/search'
selector: '.js-contact-typeahead'
hiddenSelector: '.js-contact-id'