您的位置:首页 > 产品设计 > UI/UE

解决easyUI下拉控件无法触发onkeydown事件

2017-05-17 18:54 597 查看
实现在combotree下拉控件中按Backspace键清除combotree选中的值

下面的代码无法获取到键盘事件

<input class="easyui-combotree" id="tt" name="tt" onkeydown="if(event.keyCode==8) clear()"/>


 原因是easyUI重新定义了键盘事件,解决如下:

$("#tt").combotree({
url: '../insurance/getcalInsuranceList.do',
valueField: 'id',
textField: 'text',
editable: true,
lines:true,
onlyLeafCheck:true,
panelHeight: 'auto',//高度
keyHandler: {
query: function(q,e){
//q 为输入框的文本值
if(e.keyCode==8){
$("#tt").combotree('clear')
$('#tt').combotree('hidePanel');
}
}
},
onLoadSuccess : function() {
$("#tt").combotree('tree').tree("collapseAll");//折叠所有节点
},
onBeforeSelect: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);
return false;
}
},
onClick: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
$('#tt').combotree('showPanel');
}
}
});


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐