<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Referring to parent object in JSCript</title><link>https://www.infopathdev.com:443/forums/thread/27118.aspx</link><pubDate>Mon, 10 Mar 2008 16:30:22 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:27118</guid><dc:creator>KoopLaFez</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/27118.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=27118</wfw:commentRss><description>&lt;p&gt;Thinking on this some more, I suppose I could do this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;//oTest.oChild&lt;/p&gt;
&lt;p&gt;function displayVal(){&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XDocument.UI.Alert(this.val1);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;function oChild(oTest){&lt;br /&gt;//oChild object definition&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.displayVal = displayVal;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.val1 = oTest.val1;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;//oTest&lt;/p&gt;
&lt;p&gt;function oTest(){&lt;br /&gt;//oTest object definition&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.val1 = &amp;quot;one&amp;quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.child = new oChild(this);&lt;/p&gt;
&lt;p&gt;}&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This would save me from having to pass the parent object when I am calling the displayVal method in code; however, I still have to pass the oTest object to the oChild object within the oTest object definition.&amp;nbsp; Plus, I have to define val1 twice: once in the parent object and once in the child object.&lt;/p&gt;</description></item><item><title>Referring to parent object in JSCript</title><link>https://www.infopathdev.com:443/forums/thread/27117.aspx</link><pubDate>Mon, 10 Mar 2008 16:18:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:27117</guid><dc:creator>KoopLaFez</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/27117.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=27117</wfw:commentRss><description>&lt;p&gt;Is there a way in JScript to refer to the current object&amp;#39;s parent within a method of that object&amp;nbsp;without explicitly passing the parent object to that method?&amp;nbsp; For instance: if I am in a method of an object, I can refer to the current object using the this keyword.&amp;nbsp; What I would like to do is use something along the lines of this.parent to refer to the current object&amp;#39;s parent without having to pass it to the method.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;br /&gt;//oTest.oChild&lt;br /&gt;&lt;br /&gt;function displayVal(oTest){&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XDocument.UI.Alert(oTest.val1);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function oChild(){&lt;br /&gt;//oChild object definition&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.displayVal = displayVal;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//oTest&lt;br /&gt;&lt;br /&gt;function oTest(){&lt;br /&gt;//oTest object definition&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.val1 = &amp;quot;one&amp;quot;;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.child = new oChild();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;oChild is a child object of oTest.&amp;nbsp; The displayVal method of the oChild object refers to the val1 property of oTest.&amp;nbsp; In order to do this now, I must explicitly pass the oTest object to the displayVal method when I call it.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;var myTest = new oTest();&lt;br /&gt;&amp;nbsp;myTest.child.displayVal(myTest);&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;What I would like to do is change the displayVal method so that it refers to the oTest object from within the oChild object, so it would look something like this (in pseudocode):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;function displayVal(){&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XDocument.UI.Alert(this.parent.val1);&lt;br /&gt;&amp;nbsp;&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Then, when I called the&amp;nbsp;method, I wouldn&amp;#39;t have to pass the parent object to it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;var myTest = new oTest();&lt;br /&gt;myTest.child.displayVal();&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is such a thing possible?&amp;nbsp; Is it even desireable?&amp;nbsp; Or is my need to refer to a property on a parent object symptomatic of a larger deficiency in my object structure?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>