PDA

View Full Version : Tab Content Erased After Leaving Tab



bensmurfy
26 Apr 2010, 10:24 AM
Hi All,

I hope you can help me with this. I have 4 tabs, and the problem is this. My tab content is not reloading after I say click "No" when asked if I would like to save any changes to the tab. Basically the original content is erased and all the fields are blank when I come back to the tab. Please let me know if you have any insights.


function init() {
var tabpanel = new Ext.TabPanel({
id: 'tabpanel',
deferredRender: true,
autoHeight: true,
resizable: true,
layoutOnTabChange: true,
listeners: {

beforetabchange: function (tp, nt, ct) {
if (ct) {
form = new Ext.form.BasicForm();
if (ct.title == 'Provider Info') form = Ext.getCmp('basicinfoform').getForm();
//if (ct.title == 'Billing') form = Ext.getCmp('contactinfoform').getForm();
if (ct.title == 'Portal Info') form = Ext.getCmp('portalinfoform').getForm();
if (ct.title == 'Shipping Info') form = Ext.getCmp('shippinginfoform').getForm();

if (form.isDirty()) {
Ext.Msg.show({
title: 'Save Changes?',
msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
buttons: Ext.Msg.YESNOCANCEL,
animEl: 'maintabs',
fn: function (bid, text) {
if (bid == 'yes') {
form.submit();
form.items.each(function (f) {
f.originalValue = f.getValue();
});
form.reset();
tp.activate(nt);
}
if (bid == 'no') {
form.reset();
nt.show();
}
},
icon: Ext.MessageBox.QUESTION
});
return false;

}



}




},


tabchange: function (t, tab) {
setFooter();
},





},

tobiu
26 Apr 2010, 3:05 PM
hi bensmurfy,

you use


form = new Ext.form.BasicForm();


it is called first, before checking if the form already exists.
you don't even set var form = ..., so you are using a global var. not good.

on your no-button is the call


form.reset();


which clears all fields of the form.
you don't do anything to reload the content, which seems to be what you want.


kind regards,
tobiu