我创建了一个文本框,它根据另一个列表中的数据处理自动完成功能。如果用户没有选择任何项目或他输入了错误的文本,我需要清除文本框。下面是我的代码
$.ajax({
url: "http://address/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
contentType: "text/xml; charset=\"utf-8\"",
success: function (xmlResponse) {
var domElementArray = $("z\\:row", xmlResponse);
var dataMap = domElementArray.map(function () {
return {
value: $(this).attr('ows_AirportCode'),
id: $(this).attr('ows_AirportCode')
};
});
var data = dataMap.get();
//Find the Sharepoint Portal Search Box (this is a poor selector, but it is not properly named by sharepoint, well it is but INamingContainer getrs in the way)
$("input[title='AirportCode Required Field']").autocomplete(
{
source: data,
miniLength: 3,
response: function (event, ui) {
// ui.content is the array that's about to be sent to the response callback.
if (ui.content.length == 0) {
$("#empty-message").text("No results found");
} else {
$("#empty-message").empty();
}
}
}
);
}
}); //.ajax
感谢
答案 0 :(得分:0)
您可以订阅自动填充的更改事件,并将所选值与匹配的列表值数组进行比较:
getInnerPanel