我在YUI中实现了自动完成功能.但我想做的是,当用户选择建议时,表格应与建议一起提交
<script>
YUI().use('array-extras','autocomplete','autocomplete-highlighters',function(Y) {
function locateModules(response) {
var results = [];
if(response && response.dimensions){
for (var i = 0; i < response.dimensions.length; i++) {
if(response.dimensions[i] && response.dimensions[i].refinements){
for (var j = 0; j < response.dimensions[i].refinements.length; j++) {
if(response.dimensions[i].refinements[j].refinements){
results = results.concat(response.dimensions[i].refinements[j].refinements)
}
results.push(response.dimensions[i].refinements[j]);
}
}
}
}
return Y.Array.filter(results, function(result) {
//some other conditions
return true;
});
}
Y.one('#searchId').plug(Y.Plugin.AutoComplete, {
resultHighlighter : 'phraseMatch',
resultListLocator : locateModules,
resultTextLocator : 'name',
source : '<%=autoCompleteURL%>&<portlet:namespace/>q={query}'
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
我有这样的形式
<form ...>
<input name="searchId" …Run Code Online (Sandbox Code Playgroud)