admin管理员组

文章数量:1416051

I have an ExtJs form which upon receiving a response from server shows a pop-up based on whether the submit was successful or not. The code looks like this:

if (form.isValid()) {
    form.submit({
        success: function (form, action) {
            Ext.Msg.alert('Success', action.result.msg);
        },
        failure: function (form, action) {
            Ext.MessageBox.show({
                title:'Failure',
                msg: action.result.msg,
                buttons: Ext.MessageBox.OK,
                icon: Ext.MessageBox.ERROR
            });
        }
    });
}

Now, rather than having an alert message for the success, I'd like to also have a Message box with a 'check' icon. It doesn't look like it is available in ExtJS in the same way as Ext.MessageBox.ERROR, so I was wondering how I can create a custom icon to appear there?

I have an ExtJs form which upon receiving a response from server shows a pop-up based on whether the submit was successful or not. The code looks like this:

if (form.isValid()) {
    form.submit({
        success: function (form, action) {
            Ext.Msg.alert('Success', action.result.msg);
        },
        failure: function (form, action) {
            Ext.MessageBox.show({
                title:'Failure',
                msg: action.result.msg,
                buttons: Ext.MessageBox.OK,
                icon: Ext.MessageBox.ERROR
            });
        }
    });
}

Now, rather than having an alert message for the success, I'd like to also have a Message box with a 'check' icon. It doesn't look like it is available in ExtJS in the same way as Ext.MessageBox.ERROR, so I was wondering how I can create a custom icon to appear there?

Share Improve this question edited Mar 22, 2019 at 15:56 DJDaveMark 2,86526 silver badges38 bronze badges asked Nov 9, 2012 at 15:53 Art FArt F 4,21210 gold badges52 silver badges84 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The icon config option is just a CSS class, define a new one like:

.check-icon {
    background-image: url(../img/check.png');
    background-repeat: no-repeat;
}

Then in config:

icon: 'check-icon'

Should do what you want.

本文标签: javascriptExtJs create custon icon for ExtMessageBoxStack Overflow