我有两个autosuggest
使用jquery触发输入键。代码如下
$("#Patient").autocomplete({
search: function (event, ui) {
var key = CheckBrowser(event);
if (key == 13)
return true;
else
return false;
},
source: function (request, response) {
$.ajax({
url: '@Url.Action("PatientAutoSuggestByName")',
data: { autoSuggestText: request.term }, //
dataType: 'json',
type: 'POST',
success: function (data) {
response(data);
}
});
},
select: function (event, ui) {
if (SessionExist()) {
$('#Patient_ID').val(ui.item ? ui.item.id : 0);
$('#AsterID').val(ui.item ? ui.item.code : 'Select');
$("#VisitNo").focus();
$('#VisitNo').trigger("keypress", [13]); // here i want to trigger the second auto suggest
}
}
});
第二个自动建议是
$("#VisitNo").autocomplete({
search: function (event, ui) {
var key = CheckBrowser(event);
if (key == 13)
return true;
else
return false;
},
source: function (request, response) {
$.ajax({
url: '@Url.Action("VisitorAutoSuggest")',
data: { patientID: $('#Patient_ID').val(), autoSuggestText: $('#VisitNo').val() }, //
dataType: 'json',
type: 'POST',
success: function (data) {
response(data);
}
});
},
select: function (event, ui) {
if (SessionExist()) {
$('#Visit_ID').val(ui.item ? ui.item.id : 0);
$('#VisitDate').val(ui.item ? ui.item.code : 'Select');
reloadGrid();
GetSettings();
$("#Remarks").focus();
}
}
});
我想trigger the second auto suggest on the selection of first
。我试过$('#VisitNo').trigger("keypress", [13]);
B'coz自动建议在输入键中触发。但这不起作用。如果有人知道解决方案,请分享
答案 0 :(得分:0)
as Pitchai Pazhani我说我是通过使用search method in the autocomplete
来完成的。
$("#VisitNo").autocomplete('search', $("#Patient_ID").val());