PDA

View Full Version : var scoping



raj_plays
21 Aug 2012, 2:56 AM
Hi,
This is a theoretical one.
I have 2 functions that open popup windows.
Each window has a form by the name SearchForm.
While one window is open, if I open the other one and reference SearchForm, it affects the SearchForm of both the windows.
Why is this? Doesn't each function have its own stack space?

This is how one function is declared...


function showPopup1() {
var SearchForm = new Ext.FormPanel({
labelAlign: 'top',
bodyStyle: 'padding: 5px',
labelAlign: 'left',
buttonAlign: 'left',
labelWidth: 40,
width: 200,
items: [{
layout: 'form',
border: false,
items: [{
xtype: 'textfield',
id: 'artist',
fieldLabel: 'Artist',
maxLength: 128,
anchor: '95%',
width: 160
}],
buttons: [{
text: 'Search',
handler: listSearch
}]
}]
});


var SearchWindow = new Ext.Window({
//id: 'gridSearchWindow',
closable: true,
width: 220,
height: 120,
x: 100,
y: 80,
plain: true,
layout: 'fit',
items: SearchForm
});

SearchWindow.show();
....
}

raj_plays
21 Aug 2012, 11:39 PM
The problem was that I was using the same id on 2 fields of different forms and both forms were active.

Dear Administrator, please delete this thread..

scottmartin
22 Aug 2012, 8:41 AM
We will just close. This can be helpful for others who run into the same issue.

Thanks for the update.

Scott.