更改 ext.msg.confirmation 弹出窗口中的按钮文本

发布于 2025-01-10 13:13:49 字数 1428 浏览 1 评论 0原文

我想将文本从“是”更改为“是!!!”然后“不”对“不!!!”我尝试了很多东西但似乎没有任何效果 在 Sencha 上找不到任何相关文档,如果有人可以帮忙,谢谢

Ext.application({
    name: 'Fiddle',

    launch: function() {
Ext.Msg.confirm('Confirmation', "Do you want to cancel the order?", function(btnText){
                //btnText = {
                //    yes: "YES!!",
               //   no: "NO!!"
               //}, 
               //btnText.setText("YESSS!!"),    
                if(btnText === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(btnText === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");

               }
            }, this);
    }
});

[解决方案]

Ext.application({
    name: 'Fiddle',
    launch: function() {                
        Ext.Msg.show({
        title: 'Title',
        message: 'Message',
        buttons: {
           yes: 'Cancel preAuth',
           no: 'Cancel the whole order',
           cancel: 'Do nothing!'
        },  
              fn: function(buttonValue, inputText, showConfig) {
                if(buttonValue === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(buttonValue === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");
               }
            }, this);
    }
});

I want to change the text from "yes" to "YES!!!" and "no" to "NO!!!" I tried many things but nothing seems to be working,
Couldnt find any documents on Sencha for this, if anyone can please help, Thank you

Ext.application({
    name: 'Fiddle',

    launch: function() {
Ext.Msg.confirm('Confirmation', "Do you want to cancel the order?", function(btnText){
                //btnText = {
                //    yes: "YES!!",
               //   no: "NO!!"
               //}, 
               //btnText.setText("YESSS!!"),    
                if(btnText === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(btnText === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");

               }
            }, this);
    }
});

[Solution]

Ext.application({
    name: 'Fiddle',
    launch: function() {                
        Ext.Msg.show({
        title: 'Title',
        message: 'Message',
        buttons: {
           yes: 'Cancel preAuth',
           no: 'Cancel the whole order',
           cancel: 'Do nothing!'
        },  
              fn: function(buttonValue, inputText, showConfig) {
                if(buttonValue === "yes"){
                    Ext.Msg.alert("Alert", "You have cancelled the order.");
               }
               else if(buttonValue === "no"){
                    Ext.Msg.alert("Alert", "You have confirmed 'No'.");
               }
            }, this);
    }
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮光之海 2025-01-17 13:13:49

使用 Ext.Msg.show 而不是 Ext.Msg.confirm,并为自定义按钮文本设置 buttonText。检查文档并尝试以下操作代码:

Ext.Msg.show({
    title: 'Title',
    message: 'Message',
    buttons: Ext.Msg.YESNOCANCEL,
    buttonText: {
        yes: 'MyYes',
        no: 'MyNo',
        cancel: 'MyCancel'
    },
    icon: Ext.Msg.QUESTION,
    fn: function (btn) {
        if (btn === 'yes') {
            console.log('MyYes');
        } else if (btn === 'no') {
            console.log('MyNo');
        } else {
            console.log('MyCancel');
        }
    }
});

Use Ext.Msg.show instead of Ext.Msg.confirm, and set buttonText for custom button texts. Check docs and try the following code:

Ext.Msg.show({
    title: 'Title',
    message: 'Message',
    buttons: Ext.Msg.YESNOCANCEL,
    buttonText: {
        yes: 'MyYes',
        no: 'MyNo',
        cancel: 'MyCancel'
    },
    icon: Ext.Msg.QUESTION,
    fn: function (btn) {
        if (btn === 'yes') {
            console.log('MyYes');
        } else if (btn === 'no') {
            console.log('MyNo');
        } else {
            console.log('MyCancel');
        }
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文