user3505689
user3505689

Reputation: 97

callback function in MessageBox Ext JS 4

I need validate function to return true if user agreed with alert, but the program stops and doesn't react to yes or no buttons. Any ideas? P.S. when I remove Ext.Msg.alert everything is working...

validate: function () {
    var isValid = this.callParent();
    if (isValid) {
        Ext.Msg.alert({
            title :'',
            msg : '.....',
            buttons : Ext.Msg.YESNO,
            icon: Ext.MessageBox.QUESTION,

            fn : function(btn){
                if (btn == 'yes'){
                    return true;
                }
            }
        });
    }

}

Upvotes: 1

Views: 1514

Answers (1)

sha
sha

Reputation: 17860

You can't do this. Messages are asynchronous in ExtJs.

alert will be called and execution will continue. Callback function will be called in a different queue of execution when user pressed a button.

You need to re-design your logic, so you don't depend on validate return value, but rather have couple functions - one will be called when validation succeeded and another when it failed.

Upvotes: 2

Related Questions