首页 > 其他 > 详细

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

时间:2017-05-17 19:48:44      阅读:868      评论:0      收藏:0      [点我收藏+]

实现在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‘);  
          }  
        }  
      });

  

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

原文:http://www.cnblogs.com/lujiulong/p/6869110.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!