2016-03-28 29 views
0
$(".autocomplete").autocomplete({ 
    minLength: 2, 
    selectFirst: true, 
    autoFocus: true, 
    source: 
     function (request, response) { 
      $.ajax({ 
       type: "POST", 
       url: "/airports.ashx?q=" + request.term, 
       contentType: "application/json; charset=utf-8", 
       async: false, 
       dataType: "json", 
       success: function (data) { 
        response($.map(data, function (item) { 
         return { value: item } 
        })); 
       }, 
       error: function (data) { 
        alert("An unexpected error has occurred during processing."); 
       } 
      }); 
     }, select: function (event) { 
     } 
     , close: function (event, ui) { 
      $("#txtfrom").val(ui.item.value); 
     } 
}); 
+0

你能描述一下你的問題,或許是以問題的形式? –

回答

0

放於「選擇」事件此值,它不會在「關閉」

可以試試這個.......

, select: function (event) { 
$("#txtfrom").val(ui.item.value); 
     } 
     , close: function (event, ui) { 

     } 

如果你想關閉然後使用那樣....... 聲明自動完成之外的值

var value ='';

, select: function (event) { 
value=ui.item.value; 
     } 
     , close: function (event, ui) { 
      $("#txtfrom").val(value); 
     } 
相關問題