NBRed5
13 Sep 2007, 7:35 AM
I have been building an ext application with a document tree in the west region which loads the document for edtitng in the centre region in a new panle on dblclick.
I have a event handler on the center regions 'beforeremove' event in which I check whether the document has been changed. If the document is dirty I want to use a confirmation dialog to determine whether to set the events cancel event object to true or false i.e. e.cancel = true or false.
the following code is not working (example currently uses an alert rather than confirmation) as the beforeremove event ends before the button on the alert has been pressed and control flows to the alerts callback, this results in e.cancel being set at it's default of false and the panel being removed before the result of the dialog is known, whereas I wish to set the value of e.cancel in the callback of the alert dialog.
Can anybody help, basically I amtrying to implement, 'Are you sure you want to close that as you have achnged it and not saved' functionality.
Example Code:
layout.getRegion('center').on('beforeremove', function(region,panel,e){
if (panel.code.isDirty()){
Ext.Msg.alert('Not Saved','File: ' + panel.title + ' has been changed', function(){
e.cancel = true;
});
}
});
I have a event handler on the center regions 'beforeremove' event in which I check whether the document has been changed. If the document is dirty I want to use a confirmation dialog to determine whether to set the events cancel event object to true or false i.e. e.cancel = true or false.
the following code is not working (example currently uses an alert rather than confirmation) as the beforeremove event ends before the button on the alert has been pressed and control flows to the alerts callback, this results in e.cancel being set at it's default of false and the panel being removed before the result of the dialog is known, whereas I wish to set the value of e.cancel in the callback of the alert dialog.
Can anybody help, basically I amtrying to implement, 'Are you sure you want to close that as you have achnged it and not saved' functionality.
Example Code:
layout.getRegion('center').on('beforeremove', function(region,panel,e){
if (panel.code.isDirty()){
Ext.Msg.alert('Not Saved','File: ' + panel.title + ' has been changed', function(){
e.cancel = true;
});
}
});