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

怎么能同步调用Ext.MessageBox.show ?
下面的代码,我想让Ext.MessageBox点了“OK”按钮时返回true,但是实际执行结果是:先alert了“undefined",然后才弹出Ext.MessageBox,请问要如何解决这个问题?

JScript code
    function CreateStudents(){
        var res;
        Ext.MessageBox.show({
            title: '创建学生学习帐号',
            msg: '输入学生姓名:',
            width:300,
            modal: true,
            closable: false,
            defaultTextHeight: 150,
            multiline: true,
            animEl: 'dialog',
            buttons: Ext.MessageBox.OKCANCEL,
            fn: function(btn,text){
                if(btn=='ok'){
                    if (text.trim()!=""){
                        Ext.fly('hStudents').value=text;
                        res= true;
                    }
                    res= false;
                } // end of "btn=='ok'
            }
        });
        alert(res);
        return res;
    }


------解决方案--------------------
无法解决,这个是模拟的,并不是系统的alert能阻止
alert(res);
return res;
这2句的继续执行


能只能将使用res参数的代码放到回到函数里面来