日期:2014-05-16  浏览次数:20760 次

Ext.MessageBox.show() - Web 开发 / Ajax
Ext.MessageBox.show(){
  title: 'Icon Support',
  msg: 'Here is a message with an icon!',
  buttons: Ext.MessageBox.YESCANCEL,
  fn: showResult,
  icon:'ext-mb-download'
  });

我要设置默认选中Cancel按钮,不选中Yes,怎么做

------解决方案--------------------
没试过,这两个button是不是可以设置焦点啊?
------解决方案--------------------
按F12用开发者工具或者Firebug直接观察DOM结构
直接操作DOM , <BUTTON class=x-btn-text type=button>Cancel</BUTTON>
找到class=x-btn-text并且文字为Cancel的按钮, 调用focus()
或者用 Ext.Window模拟,完全可以自己操控了.

------解决方案--------------------
在ext-all-debug.js中找到messagebox类,然后修改就可以了
JScript code

if(opt.prompt){
                d.focusEl = activeTextEl;
            }else{
                var bs = opt.buttons;
                var db = null;
                if(bs && bs.ok){
                    db = buttons["ok"];
                }else if(bs && bs.yes){
                    db = buttons["yes"];
                }
                if (db){
                    d.focusEl = db;
                }
            }