【发布时间】:2017-05-05 03:23:36
【问题描述】:
您好,我在我的应用程序中使用 dhtmlx 表单。当用户在文本框中输入文本时,我希望自动完成建议从我的数据库中出现,我可以在控制台上看到。但它没有显示为此输入框下方的建议列表。请建议我如何使这项工作......
在标题部分-
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="dhtmlx/dhtmlxSuitePRO/codebase/dhtmlx.css" />
<link rel="stylesheet" href="dhtmlx/dhtmlxScheduler/codebase/dhtmlxscheduler.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="dhtmlx/dhtmlxSuitePRO/codebase/dhtmlx.js"></script>
<script src="dhtmlx/dhtmlxScheduler/codebase/dhtmlxscheduler.js" type="text/javascript" charset="utf-8"></script>
<script src='dhtmlx/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_tooltip.js' type="text/javascript" charset="utf-8"></script>
<script src="dhtmlx/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_all_timed.js" type="text/javascript" charset="utf-8"></script>
<script src="dhtmlx/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_minical.js" type="text/javascript" charset="utf-8"></script>
<script src="dhtmlx/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_serialize.js" type="text/javascript" charset="utf-8"></script>
在脚本部分----
var layoutObj6 = document.getElementById("layoutObj6");
myLayout6.cells("a").setText(" Impersonation:");
myImpersonationFormData = [
{type: "block", list:[
{type: "input", name: "txtImpersonate", id: "txtImpersonate", offsetLeft: 0, inputWidth: 125},
{type: "newcolumn"},
{type: "button", value: "Set", name: "btn_impersonate", id: "btn_impersonate", width: 20}
]}
];
myImpersonationForm =
myLayout6.cells("a").attachForm(myImpersonationFormData);
myLayout.cells("a").appendObject(layoutObj6);
myImpersonationForm.attachEvent("onInputChange", function (name, value,myImpersonationForm){
if(name == 'txtImpersonate'){
$.ajax({
url : "/MyProject/GetUserList",
type : "GET",
data : { user : value},
dataType : "jsonp",
success : function(data) {
response(data.userList);// can see the list in browser console
},
error: function(jqXHR, textStatus, errorThrown){
alert("ERROR!!! \n \n System Error code: " + jqXHR.status + "\n \n Please contact Server administrator.);
}
});
}
});
【问题讨论】:
标签: jquery ajax autocomplete jquery-ui-autocomplete dhtmlx