jquery autoComplete 自動完成
阿新 • • 發佈:2019-01-26
//動態註冊自動填充控制元件(訓練場地)
function autoRegisterClassroom(obj,num){
//自動完成訓練場地
var optionsClassroom = {
//最小匹配字數
minChars: 0,
//層顯示條目數
max:10,
//層寬度
width: 400,
//包含匹配
matchContains: false,
//是否必須匹配
mustMatch: true,
//多選
multiple: false,
//自動填充
//autoFill: true,
/** 大資料量時使用方法 **/
extraParams: {
ajaxKeyWord:function(){return encodeURI(jQuery(obj).val())},classRoom_type:
function(){
return encodeURI(jQuery("input[name='classroomType']").val())
}
},
parse : function(data) {
return jQuery.map(eval(data), function(row) {
return {data : row, value : row.CLASSROOMID, result : row.CLASSROOMNAME}
});
},
formatItem: function(row, i, max){
return row.CLASSROOMNAME;
},
formatMatch: function(row, i, max){
//使用漢字或拼音(makePy)匹配
return row.CLASSROOMNAME + " " + makePy(row.CLASSROOMNAME);
},
formatResult: function(row){
return row.CLASSROOMNAME;
}
};
jQuery(obj).autocomplete("/jwcore/ajaxFindAllClassRoomAction.do?", optionsClassroom);
//選中條目時執行
jQuery(obj).result(function(event, data, formatted){
if(data == null){
document.getElementsByName("flxedClassroomID")[num].value = '';
}
if(data != null && data.CLASSROOMID != null && data.CLASSROOMID != ""){
document.getElementsByName("flxedClassroomID")[num].value = data.CLASSROOMID;
}
});
}
function autoRegisterClassroom(obj,num){
//自動完成訓練場地
var optionsClassroom = {
//最小匹配字數
minChars: 0,
//層顯示條目數
max:10,
//層寬度
width: 400,
//包含匹配
matchContains: false,
//是否必須匹配
mustMatch: true,
//多選
multiple: false,
//自動填充
//autoFill: true,
/** 大資料量時使用方法 **/
extraParams: {
ajaxKeyWord:function(){return encodeURI(jQuery(obj).val())},classRoom_type:
function(){
return encodeURI(jQuery("input[name='classroomType']").val())
}
},
parse : function(data) {
return jQuery.map(eval(data), function(row) {
return {data : row, value : row.CLASSROOMID, result : row.CLASSROOMNAME}
});
},
formatItem: function(row, i, max){
return row.CLASSROOMNAME;
},
formatMatch: function(row, i, max){
//使用漢字或拼音(makePy)匹配
return row.CLASSROOMNAME + " " + makePy(row.CLASSROOMNAME);
},
formatResult: function(row){
return row.CLASSROOMNAME;
}
};
jQuery(obj).autocomplete("/jwcore/ajaxFindAllClassRoomAction.do?", optionsClassroom);
//選中條目時執行
jQuery(obj).result(function(event, data, formatted){
if(data == null){
document.getElementsByName("flxedClassroomID")[num].value = '';
}
if(data != null && data.CLASSROOMID != null && data.CLASSROOMID != ""){
document.getElementsByName("flxedClassroomID")[num].value = data.CLASSROOMID;
}
});
}