nl65
14 Oct 2012, 7:37 PM
I would like to warn the user upon leaving a form without saving the changes.
So, I try to detect a blur from a form, however the event does not fire.
Perhaps other idea how to achieve it ?
Ext.define('MyApp.view.MyViewport', { extend: 'Ext.container.Viewport',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: 'Test Form',
items: [
{
xtype: 'form',
layout: {
type: 'auto'
},
bodyPadding: 10,
title: 'Form1',
pollForChanges: true,
items: [
{
xtype: 'textfield',
value: 'Original Text',
fieldLabel: 'Change Me'
},
{
xtype: 'button',
text: 'Save'
}
],
listeners: {
blur: {
fn: me.onFormBlur,
scope: me
}
}
}
]
},
{
xtype: 'panel',
title: 'Some Other Form',
tabConfig: {
xtype: 'tab',
width: 127
},
items: [
{
xtype: 'form',
bodyPadding: 10,
title: 'Form2',
items: [
{
xtype: 'textfield',
fieldLabel: 'Change Me Too'
}
]
}
]
}
]
}
]
});
me.callParent(arguments);
},
onFormBlur: function(abstractcomponent, e, options) {
alert('onFormBlur');
}
});.
So, I try to detect a blur from a form, however the event does not fire.
Perhaps other idea how to achieve it ?
Ext.define('MyApp.view.MyViewport', { extend: 'Ext.container.Viewport',
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
xtype: 'tabpanel',
activeTab: 0,
items: [
{
xtype: 'panel',
title: 'Test Form',
items: [
{
xtype: 'form',
layout: {
type: 'auto'
},
bodyPadding: 10,
title: 'Form1',
pollForChanges: true,
items: [
{
xtype: 'textfield',
value: 'Original Text',
fieldLabel: 'Change Me'
},
{
xtype: 'button',
text: 'Save'
}
],
listeners: {
blur: {
fn: me.onFormBlur,
scope: me
}
}
}
]
},
{
xtype: 'panel',
title: 'Some Other Form',
tabConfig: {
xtype: 'tab',
width: 127
},
items: [
{
xtype: 'form',
bodyPadding: 10,
title: 'Form2',
items: [
{
xtype: 'textfield',
fieldLabel: 'Change Me Too'
}
]
}
]
}
]
}
]
});
me.callParent(arguments);
},
onFormBlur: function(abstractcomponent, e, options) {
alert('onFormBlur');
}
});.