<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; nested</title>
	<atom:link href="http://seanbehan.com/tag/nested/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Accessing Links in Nested TD Cells with Prototype</title>
		<link>http://seanbehan.com/javascript/accessing-links-in-nested-td-cells-with-prototype/</link>
		<comments>http://seanbehan.com/javascript/accessing-links-in-nested-td-cells-with-prototype/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 21:59:42 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[$$]]></category>
		<category><![CDATA[code optimization]]></category>
		<category><![CDATA[nested]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[tables]]></category>
		<category><![CDATA[td]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=618</guid>
		<description><![CDATA[There must be a better way to do the following with PrototypeJS. I want to loop over nested links inside of table td cells and apply a class to the row that the link is in when the link is clicked. If a user clicks on another link the class will be removed and applied [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fjavascript%2Faccessing-links-in-nested-td-cells-with-prototype%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Accessing Links in Nested TD Cells with Prototype" data-url="http://seanbehan.com/javascript/accessing-links-in-nested-td-cells-with-prototype/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>There must be a better way to do the following with PrototypeJS. I want to loop over nested links inside of  table td cells and apply a class to the row that the link is in when the link is clicked. If a user clicks on another link the class will be removed and applied to the current table row.</p>
<p>The code below works but I think it seems hackish. Any thoughts on improving this code?</p>
<p>Here is the link to the pastie <a href="http://pastie.org/703316">http://pastie.org/703316</a></p>
<pre class="wp-code-highlight prettyprint">
# This is the table with haml markup
%table
  %tr
    %td
       info
    %td
      = link_to &quot;be clicked&quot;, remote_request_goes_here_path
</pre>
<p>And the Js</p>
<pre class="wp-code-highlight prettyprint">
	$$(&quot;td.filter_link &gt; a&quot;).each(function(element){
		Event.observe(element, &quot;click&quot;, function(event){
			$$(&quot;td.filter_link&quot;).each(function(el){
				if(el != this){
					el.up().removeClassName(&quot;turnwhite&quot;);
				}
			});
                       // apply the turnwhite class to the table row
			this.up().up().addClassName(&quot;turnwhite&quot;);
		});
	});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/javascript/accessing-links-in-nested-td-cells-with-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nested Attributes in a Form for Has_One Model Association in Rails</title>
		<link>http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/</link>
		<comments>http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 17:13:50 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[has_one]]></category>
		<category><![CDATA[nested]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=449</guid>
		<description><![CDATA[Just for reference&#8230; class Member &#60; ActiveRecord::Base has_one :member_profile accepts_nested_attributes_for :member_profile end &#60;p&#62; &#60;% form_for @member do &#124;f&#124; -%&#62; &#60;%= f.label :fullname %&#62; &#60;%= f.text_field :fullname %&#62; &#60;% f.fields_for :member_profile, @member.member_profile do &#124;member_profile&#124;%&#62; &#60;p&#62;&#60;%= member_profile.label :about %&#62;&#60;%= member_profile.text_field :about %&#62;&#60;/p&#62; &#60;p&#62;&#60;%= member_profile.label :favorite_color %&#62;&#60;%= member_profile.text_field :favorite_color %&#62;&#60;/p&#62; &#60;% end %&#62; &#60;/p&#62;]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Fnested-attributes-in-a-form-for-has_one-model-association-in-rails%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Nested Attributes in a Form for Has_One Model Association in Rails" data-url="http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Just for reference&#8230;</p>
<pre class="wp-code-highlight prettyprint">
class Member &lt; ActiveRecord::Base
    has_one :member_profile
    accepts_nested_attributes_for :member_profile
end
</pre>
<pre class="wp-code-highlight prettyprint">
&lt;p&gt;
&lt;% form_for @member do |f| -%&gt;
       &lt;%= f.label :fullname %&gt; &lt;%= f.text_field :fullname %&gt;
	&lt;% f.fields_for :member_profile, @member.member_profile do |member_profile|%&gt;
               &lt;p&gt;&lt;%= member_profile.label :about %&gt;&lt;%= member_profile.text_field :about %&gt;&lt;/p&gt;
               &lt;p&gt;&lt;%= member_profile.label :favorite_color %&gt;&lt;%= member_profile.text_field :favorite_color %&gt;&lt;/p&gt;
	&lt;% end %&gt;
&lt;/p&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

