0

検索対象の都市の緯度と経度を返すオートコンプリート検索フィールドがあります。

何らかの理由で、提案された結果の「選択」に、「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
4

1 に答える 1

0

ここで答えが見つかりました:jquery ui autocomplete added a span

もう一度質問して申し訳ありませんが、当時は探すのが難しくてあいまいな質問でした.

于 2012-12-04T19:56:19.673 に答える