EasyUI使用技巧总结

combobox组件

一、禁用combobox里面的输入框

$("选择器").combo('textbox').attr("readonly", "readonly");
$('选择器').combobox({

  editable:false ,
    panelheight:300
});

 

二、禁用

  $('选择器').combobox('disable');

 

三、获取选项文本和值

$("选择器").combobox("getText")//获取选项文本

$("选择器").combobox("getValue")//获取选项值

四、聚焦自动展开,回车do someting

$("选择器").focus(function () {
    $(this).combo('showPanel');
    $(this).combo('textbox').focus();
    $($(this).combo('textbox')).unbind("keyup").bind("keyup", function (e) {
        if (e.keyCode == 13) {

            //do someting
        }
    });
});

 

 

二、弹出层弹出时默认第一个按钮有焦点按回车键可以执行相应函数后关闭,但在cs程序中使用webbrowser显示后不可用了。

所以有了下面方法,监听body  keyup事件,不同的是按钮有没焦点都能激发点击事件,这样也更像模态窗口。(此方法如果在弹出窗口中操作按回车会关闭,不可取)

 1 $('body').live('keyup',function(e){
 2     if(e.keyCode == 13){
 3 
 4         $('.window').map(function(){
 5 
 6             if($(this).css('display') == 'block'){
 7                 $(this).find('.messager-button').children("a:first").click();
 8                 $(this).find('.dialog-button').children("a:first").click();
 9             }
10         
11         });
12 
13     }
14 });
View Code

 

注:看到很多园友写相关文章,也用上了,感觉上了贼船,好慢。页面加载时有两秒左右全白(只是引用库文件),那么多人用性能应该还可以吧。望大牛指点一二。

posted @ 2013-11-22 00:01  jewely  阅读(15395)  评论(0编辑  收藏  举报