我是 jquery 的新手。我已经阅读并尝试了自动完成方法中的许多不同事件来做我想做的事但没有成功。
无论如何,我有一个自动完成功能如下
$(document).ready(function () {
$("#SearchContactWorker")
.each(function () {
var urlloc = "/Worker/FindWorkers";
$(this).autocomplete({
source: function (request, response) {
$.ajax({
url: urlloc, type: "POST", dataType: "json",
data: { searchString: request.term, maxResults: 10 },
success: function (data) {
response($.map(data, function (item) {
return { label: item.name, value: item.name, id: item.id }
}))
}
})
},
select: function (event, ui) {
$("[id$='ContactID']").val(ui.item.id);
}
});
});
});
Curently when a item is selected I save the ID in a hidden input called ContactID Now if the user enters some text that does not return any results I want to save that text against a different hidden input type called ContactFullName .How do I do this? ?
提前致谢