我有两个autosuggest
使用 jquery 触发 enter key 。代码如下
$("#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 自动建议是在输入键中触发的。但这不起作用。如果有人知道解决方案,请分享