2017-07-14 77 views
0

我已經設法從數據庫中提取結果,並且給出的var products是我在檢查元素時看到的結果。唯一的問題是應該包含結果的列表不可見。自動完成不會顯示列表中的結果

我也試圖檢查元素列表,所以這是我

<ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" tabindex="0" style="display: none; top: 136px; left: 865px; width: 402px;"> 
    <li class="ui-widget-content ui-menu-divider"></li> 
</ul> 

一個空白列表。這是第一次嘗試自動完成。如果可以,請幫忙。

$(function() { 
 
    { 
 
    var products = [{ 
 
     "product_code": "ABC1233", 
 
     "product_id": 1, 
 
     "product_name": "National Stove Testing" 
 
    }]; 
 
    $("#find_product").autocomplete({ 
 
     source: products, 
 
     select: function(even, ui) { 
 
     $("#id").val(ui.item.id); //ignore this 
 
     $("#name").val(ui.item.value); //ignore this 
 
     $("#type").val(ui.item.type); //ignore this 
 
     } 
 
    }); 
 
    } 
 
});
<div class="ui-widget"> 
 
    <label for="find_product">Find Product: </label> 
 
    <input id="find_product"> 
 
</div>

回答

1

小提琴 - http://jsfiddle.net/darjiyogen/kq7pL4kh/1/

$(document).ready(function() { 
 
var products = [{ 
 
    "value": "aBCD", 
 
    "id": 1, 
 
    "label": "National Stove Testing" 
 
},{ 
 
    "value": "EF", 
 
    "id": 2, 
 
    "label": "WEWE Stove Testing" 
 
}]; 
 

 
$("#find_product").autocomplete({ 
 
    source: products, 
 
     minLength: 1 
 
}); 
 

 
});
<div class="ui-widget"> 
 
    <label for="find_product">Find Product: </label> 
 
    <input id="find_product"> 
 
</div>

+0

是的,我得到了已經!不管怎麼說,多謝拉 :) –

相關問題