This content has been marked as final. Show 5 replies
UPDATE: I found a solution that works, however, if somebody could explain why this works and the other doesn't, it'd be appreicated. See updated code below:
When you create a variable in a function, it will only exist as long as the function runs, and gets deleted when the function ends. So the line inside the constructor creates a variable 'class' that only exist in the instantiation, outside that '_class' will be undefined.
The same goes for the line in the function loadXML(), but that's the place where the var gets used, so now it's working.
You could also make the _class var a class variable and assign the reference in the constructor, then the var would be available as long as the object exists.
Thank-you for your solution, however, that is actually a mistake in my post. In my actual project, i had defined the _class var outside of the constructor.
P.S. I edited the above postings to correct the error previously mentioned.
Inside call back handlers the class members are out of scope, including the var _class you declared. In your code in the function loadXML() the declaration var _class=this; creates a new (!) variable with a scope local to the function holding a reference to the current object/class.