Reputation: 6411
My code snipet looks like :
<s:HGroup horizontalAlign="center">
<s:Label text="Anul : " paddingTop="5"/>
<s:ComboBox id="yearsCb" change="yearsCb_changeHandler(event)" labelField="year"/>
</s:HGroup>
Also, in my code, after I open a popup, I encounter the following code :
trace(yearsCb.selectedItem.year);
that throws the infamous error :
TypeError: Error #1010: A term is undefined and has no properties. at Function/netcom.vort3x.agr_reg.client.builders.chapters.cont....
Do you have idea about the reason for that error and how to prevent it?
N.B. The code that triggers this error is as a result for click handler. If before encountering this error change the selection on my yearsCb, everithing is fine.
EDIT:
I forget to specify that this error is thrown when it is a selected item in my ComboBox. It seem that after container that holds the ComboBox loses the focus, it doesn't recognize it's ComboBox child as having a selected item anyway (this problem arise only after the modal popup close.).
Upvotes: 1
Views: 447
Reputation: 8050
You could extend the ComboBox
control to store the selectedItem
object in a variable when an item is picked from the popup or you could store that value outside of the control in a variable somewhere else in your app so it can be referenced later.
Also, if the ComboBox
's dataProvider
is created dynamically or destroyed after the popup closes, you'll want to store the selectedItem
using ObjectUtil.copy
since the original item your variable was referencing would have been destroyed.
Upvotes: 1
Reputation: 2142
you can prevent it using:
if(yearsCb.selectedItem != null){
}
Upvotes: 1