検索対象の都市の緯度と経度を返すオートコンプリート検索フィールドがあります。
何らかの理由で、提案された結果の「選択」に、「ui-helper-hidden-accessible」のクラスと「status」の役割を持つスパンがあり、非表示から表示に変わり、結果の選択された値が表示されます。
「select」イベントにオートコンプリートからの戻り値を別の非表示のテキストフィールドに入力するように指示するコードの最後の行をコメントアウトしても、この「非表示」スパンは返されたオートコンプリート値とともに表示されるため、奇妙です。
何が起こっている???
これは参考のために私のCoffeescriptです
myGeocodeAutocomplete = ->
$('[type="text"][name*="[geocode_location]"]').autocomplete
source: (request, response) ->
$.ajax
url: "http://ws.geonames.org/searchJSON"
dataType: "jsonp"
data:
featureClass: "P"
style: "full"
maxRows: 12
name_startsWith: request.term
success: (data) ->
response $.map(data.geonames, (item) ->
label: item.name + ((if item.adminName1 then ", " + item.adminName1 else "")) + ", " + item.countryName
value: item.lat + ", " + item.lng
)
minLength: 2
open: ->
$(this).removeClass("ui-corner-all").addClass "ui-corner-top"
close: ->
$(this).removeClass("ui-corner-top").addClass "ui-corner-all"
focus: (event, ui) ->
event.preventDefault()
$(this).val ui.item.label
select: (event, ui) ->
event.preventDefault()
$(this).val ui.item.label
$(this).siblings('[name*="[geocode_ll]"]').val ui.item.value