Return Values ​​from a Modal Dialog in ExtJs 4

I am trying to override window.confirm in ExtJS 4. Termination should return true or false (exactly the same as confirm, but with a great user interface).

window.confirm=function(msg) {var val=Ext.create("Ext.Window",{ title : 'Extra window!', width : 150, height: 100, closable : true, html : msg, modal : true, onEsc:aa, items:[ { xtype:'button', text:'Ok', handler:function() { return true; } }, { xtype:'button', text:'Cancel', handler:function(){ return false; } } ] }).show(); function aa(btn) { return false; } 

I get a modal window wherever I use confirmation, but it does not return either true or false, it works asynchronously.

I tried with showModalDialog instead of confirming, this time, too, I am not getting the return value.

Is it possible to return true or false based on the user's choice (when the user selects ok and then returns true, false when clicking cancel)

+4
source share
1 answer

You cannot invoke a modal dialog synchronously. If you want to somehow wrap it in a utility function that you will call from different places in your application, you need to do something like this:

 showConfirmationDialog: function(question, yesCallback) { //... Create you window //... Show window - add handler to the YES button and call yesCallback from it }, ... otherFunction: function() { this.showConfirmationDialog('Do you want to delete record?', function() { // Delete record }); } 
+4
source

All Articles