External return value of the internal function Ext.Msg.confirm

I need to create a function that returns a result (boolean) when the user clicks "yes" or "no". I am using Ext.Msg.confirm

. Below is my function (testcase).

function returnAnswer() {

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

      

In the above function, the callback function is returning the result, not my actual function.
How can I get the function returnAnswer

to return the result?

Thanks in advance.

+3


source to share


2 answers


returnAnswer

callback should pass:



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

      

+3


source


You can use window.confirm()

, it returns boolean.



0


source







All Articles