I have combos in my extjs application and I want to show 'Are you sure?' confirm the window to the user and prevent the change if the user says no.
Since the JavaScript confirmation window is synchronous, it works correctly. But using Ext JS, a confirmation message is displayed, and the rest of my code will be executed before the user responds. Here is my code:
// JavaScript confirm box { xtype: 'combo', ... ... ... listeners: { beforeselect: function(combo, record, index ) { if(confirm('Are you sure ?') == false) { return false; // prevent combo from changing } // else continue } } } // Ext JS message box (to confirm) { xtype: 'combo', ... ... ... listeners: { beforeselect: function(combo, record, index ) { Ext.Msg.show({ title: 'Warning', msg: 'Are You Sure ?', buttons: Ext.Msg.YESNO, fn: function(btn) { if (btn == 'yes') { // continue and set new value on combo } else if (btn == 'no') { // prevent combo from changing } } }); } } }
The problem is that Ext.Msg.show receives the callback function and does not wait for the user to respond, and we cannot prevent the change of lists with the list.
What should I do?
source share