首页 > 解决方案 > 我需要在警报框消息中写入名字,例如如果我输入名字杰克,那么警报会像杰克登录成功一样出现

问题描述

我需要在警报框消息中写入名字,例如如果我输入名字杰克,那么警报会像杰克登录成功一样出现。

defaultType: 'textfield',
    items: [{
        fieldLabel: 'First Name',
        itemId:'fname',
        name: 'first',
        allowBlank: false
    },{
        fieldLabel: 'Last Name',
        name: 'last',
        allowBlank: false
    },{
        fieldLabel: 'User Name',
        name: 'uName',
        allowBlank: false,
        emptyText:'User Id'
    },{
        fieldLabel: 'Password',
        name: 'passWd',
        allowBlank: false,
        inputType:'Password'
    }],

// Reset and Submit buttons
buttons: [{
    text: 'Reset',
    handler: function() {
        this.up('form').getForm().reset();
    }
}, {
    text: 'Login',
    formBind: true, //only enabled once the form is valid
    listeners: {
              click: function() {
                 Ext.Msg.alert('Login Successfully');    
       }

标签: extjs

解决方案


看看这个小提琴

代码片段:

{
    text: 'Login',
    formBind: true, //only enabled once the form is valid
    listeners: {
        click: function () {
            var fname = this.up('form').down('#fname').getValue();
            Ext.Msg.alert('Success!', fname + ' login successfully');
        }
    }
}

推荐阅读