PDA

View Full Version : Check whether a page is dirty or not before closing



funnyfox
17 Sep 2012, 9:23 AM
My Application has many forms. All of the js files are similar to the one below.

I want to check whether the page is dirty or not while clicking on close button.
I tried some ways by searching on the internet but none of them worked.

Can anyone suggest me an easy way to do this.


Ext.define('tz.ui.EmployeeDetailPanel', {
extend: 'tz.ui.BaseFormPanel',
bodyPadding: 10,
title: '',
anchor:'100% 95%',
autoScroll:true,
fieldDefaults: { msgTarget: 'side',labelAlign: 'right'},
initComponent: function() {
var me = this;
me.dockedItems = [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'button',
text: 'Save',
iconCls : 'btn-save',
scope: this,
handler: this.saveEmployee
},'-',
{
xtype: 'button',
text: 'Delete',
iconCls : 'btn-delete',
scope : this,
handler: function(){
this.deleteConfirm();
}
},'-',
{
xtype: 'button',
text: 'Close',
iconCls : 'btn-close',
handler: function(){
app.employeeMgmtPanel.closeEmployeeDetail();
}
]
}
];
me.items = [this.getMessageComp(), this.getHeadingComp(),
{
xtype:'fieldset',
title: 'Employee Information',
collapsible: true,
layout: 'column',
items :[{
xtype: 'container',
columnWidth:.5,
items: [{
xtype:'textfield',
fieldLabel: 'First Name',
name: 'firstName',
allowBlank:false,
tabIndex:1
},{
xtype:'textfield',
fieldLabel: 'Email',
name: 'emailId',
allowBlank:false,
tabIndex:3
},{
xtype:'textfield',
fieldLabel: 'Home Phone',
name: 'homePhone',
allowBlank:false,
tabIndex:5
},{
xtype:'textfield',
fieldLabel: 'Work Phone',
name: 'workPhone',
tabIndex:7
},{
xtype:'textfield',
fieldLabel: 'Cell Phone',
name: 'cellPhone',
tabIndex:9
}
]
}
];
me.callParent(arguments);
},

scottmartin
17 Sep 2012, 1:03 PM
See if this will help:
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-isDirty

Scott.