javascript - Ext.Msg.confirm inside function return value - Stack Overflow

I need to create a function that returns a (boolean)result when the user clicks yes or no. I'm usi

I need to create a function that returns a (boolean)result when the user clicks yes or no. I'm using a Ext.Msg.confirm. Below my function (testcase).

function returnAnswer() {
    Ext.Msg.confirm(
        'HardCoded',
        'Do you want hard-coded strings in your application?', 
        function(btn) {
            return btn === 'yes';
        }
    );
}

In the above function a "callback" function returns a result and not my actual function.
How can I get returnAnswer function return a result?

Thanks in advance.

I need to create a function that returns a (boolean)result when the user clicks yes or no. I'm using a Ext.Msg.confirm. Below my function (testcase).

function returnAnswer() {
    Ext.Msg.confirm(
        'HardCoded',
        'Do you want hard-coded strings in your application?', 
        function(btn) {
            return btn === 'yes';
        }
    );
}

In the above function a "callback" function returns a result and not my actual function.
How can I get returnAnswer function return a result?

Thanks in advance.

Share Improve this question edited Sep 18, 2024 at 16:32 A1rPun asked Feb 13, 2013 at 8:27 A1rPunA1rPun 16.9k8 gold badges59 silver badges92 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

returnAnswer should pass a callback:

function returnAnswer(callback) {
    Ext.Msg.confirm('HardCoded', 'Do you want hard-coded strings in your application?', 
    function(btn) {
       callback.call(this, btn === 'yes');
    });
}

You can use window.confirm() it returns boolean value.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742275394a4413492.html

相关推荐

  • javascript - Ext.Msg.confirm inside function return value - Stack Overflow

    I need to create a function that returns a (boolean)result when the user clicks yes or no. I'm usi

    23小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信