好的,我不确定这是不是最好的方法,但它对我有效。我使用了jquery-ui-autocomplete - 和JSON API插件
首先从上面的链接下载所需的js文件。我使用了Google libraryInstall中的jqueri ui并激活JSON API插件
然后,在自定义帖子表单的“标题”输入字段中键入内容时,我使用以下javascript自动建议
<script type="text/javascript">
$(function() {
$(\'#title\').autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://example.com/?json=1&include=title",
dataType: "json",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.posts, function( item ) {
return {
label: item.title,
value: item.title
}
}));
}
});
},
minLength: 2,
});
});
</script>
下一步是让它与自定义分类法一起工作!