Hey there,
Any idea about the following problem ?
The following code for the ExtractDataFromXmlTag constructor works
fine.
oXmlDoc is a XML document (;o) and aTagArray an array of some tags of
this document. There are some
additionnal methods in this class but nevermind.
var ExtractDataFromXmlTag = Class.create();
ExtractDataFromXmlTag.prototype = {
initialize : function (oXmlDoc, aTagArray) {
this.xmldoc = oXmlDoc;
this.tagArray = aTagArray;
this.childArray = {};
for each (tag in this.tagArray) {
this.childArray[tag] this.xmldoc.getElementsByTagName(tag);
};
return this.childArray;
},
...
};
The following code don''t works ... it returns error:
"this.xmldoc
has no properties"
(inside the loop).
var ExtractDataFromXmlTag = Class.create();
ExtractDataFromXmlTag.prototype = {
initialize : function (oXmlDoc, aTagArray) {
this.xmldoc = oXmlDoc;
this.tagArray = aTagArray;
this.childArray = {};
this.tagArray.each ( function(tag) {
this.childArray[tag] this.xmldoc.getElementsByTagName(tag);
});
return this.childArray;
},
...
};
I''m pretty sure this is a scope problem but I can''t figure it
out.
Another exemple:
var maxNbChild = this.tagArray.max (function (tag) { return
this.childArray[tag].length;});
returns "this.childArray has no properties"
Enabling Firebug (in FF 2.0.0.2) I can see that that "this" object has
changed, but I don''t know
if this is simply a side effect.
Regards
Claude
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---