autocomplete hov to using source function

时间:2018-02-07 17:14:31

标签: jquery jquery-ui-autocomplete

我有autocoplete代码:

["id":"100","value":"ActionScript","label":"ActionScript","desc":"ActionScript"},{"id":"200","value":"AppleScript","label":"AppleScript","desc":"AppleScript"},{"id":"300","value":"Asp","label":"Asp","desc":"Asp"},{"id":"400","value":"BASIC","label":"BASIC","desc":"BASIC"}]

autocomplete.txt文件的内容:

var availableTags=[{"id":"100","value":"ActionScript","label":"ActionScript","desc":"ActionScript"},     
{"id":"200","value":"AppleScript","label":"AppleScript","desc":"AppleScript"},     {"id":"300","value":"Asp","label":"Asp","desc":"Asp"},    {"id":"400","value":"BASIC","label":"BASIC","desc":"BASIC"}];

$( "#autocomplete" ).autocomplete({
source: availableTags,
minLength: 2,
select: function (event, ui)
{
    var test = ui.item ? ui.item.id : 0;
    if (test > 0)
    {
       alert(test);
    }
}

当我在输入字段中输入任何字符时,结果我会得到“autocomplete.txt'”的完整列表。内容,而不仅仅是具有匹配字符的单词。当我使用这段代码时:

library(sf)
library(spdep)
nc <- st_transform(st_read(system.file("shape/nc.shp", package="sf")), 32618)
# create points
pts <- st_centroid(nc)

dis <- 50000

# quickest solution:
x <- spdep::dnearneigh(sf::st_coordinates(pts), 0, dis)

一切都很好,自动填充只搜索匹配的单词。为什么没有正确使用自动完成.txt&#39;文件?

0 个答案:

没有答案