<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How to dynamically update form elements in Rails using Ajax</title>
	<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/</link>
	<description></description>
	<pubDate>Thu, 28 Aug 2008 08:21:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: Michael</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-669</link>
		<pubDate>Tue, 18 Sep 2007 02:27:26 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-669</guid>
					<description>This isn't working for me...

When I select an option from the first SELECT field, the second SELECT field just grays out. Any ideas?

Thanks.</description>
		<content:encoded><![CDATA[<p>This isn&#8217;t working for me&#8230;</p>
<p>When I select an option from the first SELECT field, the second SELECT field just grays out. Any ideas?</p>
<p>Thanks.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jake</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-544</link>
		<pubDate>Thu, 30 Aug 2007 14:06:05 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-544</guid>
					<description>LOL! Do-over:

I’ve heard that IE doesn’t like to replace the &#60;option&#62; contents of a &#60;select&#62;, so the thing to do here is to wrap the &#60;select&#62; in a span/div/whatever and replace the whole &#60;select&#62; each time.</description>
		<content:encoded><![CDATA[<p>LOL! Do-over:</p>
<p>I’ve heard that IE doesn’t like to replace the &lt;option&gt; contents of a &lt;select&gt;, so the thing to do here is to wrap the &lt;select&gt; in a span/div/whatever and replace the whole &lt;select&gt; each time.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jake</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-543</link>
		<pubDate>Thu, 30 Aug 2007 14:03:59 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-543</guid>
					<description>I've heard that IE doesn't like to replace the  contents of a , so the thing to do here is to wrap the  in a span/div/whatever and replace the whole .</description>
		<content:encoded><![CDATA[<p>I&#8217;ve heard that IE doesn&#8217;t like to replace the  contents of a , so the thing to do here is to wrap the  in a span/div/whatever and replace the whole .
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Matt Caza</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-389</link>
		<pubDate>Fri, 13 Jul 2007 00:59:43 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-389</guid>
					<description>Hi. I posted a question on this to http://railsforum.com/viewtopic.php?pid=31045#p31045
if you have any thoughts, that would be great...</description>
		<content:encoded><![CDATA[<p>Hi. I posted a question on this to <a href='http://railsforum.com/viewtopic.php?pid=31045#p31045' rel='nofollow'>http://railsforum.com/viewtopic.php?pid=31045#p31045</a><br />
if you have any thoughts, that would be great&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Chris Ortman</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-385</link>
		<pubDate>Wed, 11 Jul 2007 19:10:38 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-385</guid>
					<description>Does this work in IE?</description>
		<content:encoded><![CDATA[<p>Does this work in IE?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: matt schick</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-377</link>
		<pubDate>Thu, 28 Jun 2007 22:43:54 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-377</guid>
					<description>ack, I can't  seem to get the damn line of code to post (probably should have read all the comments before posting).  Here is the line of code minus the open close brackets, percent signs, and leading equal sign:

options_from_collection_for_select @states, 'id', 'name'</description>
		<content:encoded><![CDATA[<p>ack, I can&#8217;t  seem to get the damn line of code to post (probably should have read all the comments before posting).  Here is the line of code minus the open close brackets, percent signs, and leading equal sign:</p>
<p>options_from_collection_for_select @states, &#8216;id&#8217;, &#8216;name&#8217;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: matt schick</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-375</link>
		<pubDate>Thu, 28 Jun 2007 22:39:54 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-375</guid>
					<description>Thanks for the walk through, saved me loads of time. And to add to it: one way to make this concept even shorter (albeit a bit more terse) is to use the options_from_collection_for_select in the "get_cities.rhtml" file.  For the example above just replace the 3 lines with this one line:



thanks again!</description>
		<content:encoded><![CDATA[<p>Thanks for the walk through, saved me loads of time. And to add to it: one way to make this concept even shorter (albeit a bit more terse) is to use the options_from_collection_for_select in the &#8220;get_cities.rhtml&#8221; file.  For the example above just replace the 3 lines with this one line:</p>
<p>thanks again!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Johan Bryntesson</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-372</link>
		<pubDate>Mon, 25 Jun 2007 16:04:50 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-372</guid>
					<description>Grrr!! It's the form that's editing whar I type!!!
Again Neal, please edit...

The line in the form, embedded in less-than + percent

observe_field 'user[list]', :url =&#62; {:action =&#62; 'updateform'}, :with =&#62; 'id'</description>
		<content:encoded><![CDATA[<p>Grrr!! It&#8217;s the form that&#8217;s editing whar I type!!!<br />
Again Neal, please edit&#8230;</p>
<p>The line in the form, embedded in less-than + percent</p>
<p>observe_field &#8216;user[list]&#8217;, :url =&gt; {:action =&gt; &#8216;updateform&#8217;}, :with =&gt; &#8216;id&#8217;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Johan Bryntesson</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-371</link>
		<pubDate>Mon, 25 Jun 2007 16:02:55 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-371</guid>
					<description>Sorry... the line in post #5 starting with {:action =&#62;
should have read:

 {:action =&#62; 'updateform'}, :with =&#62; 'id' %&#62;

Neal, please feel free to edit this to distill out the useful parts. If any!</description>
		<content:encoded><![CDATA[<p>Sorry&#8230; the line in post #5 starting with {:action =&gt;<br />
should have read:</p>
<p> {:action =&gt; &#8216;updateform&#8217;}, :with =&gt; &#8216;id&#8217; %&gt;</p>
<p>Neal, please feel free to edit this to distill out the useful parts. If any!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Johan Bryntesson</title>
		<link>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-370</link>
		<pubDate>Mon, 25 Jun 2007 16:00:42 +0000</pubDate>
		<guid>http://nealenssle.com/blog/2007/04/12/how-to-dynamically-update-form-elements-in-rails-using-ajax/#comment-370</guid>
					<description>At last! Excuse my incessant ranting, but I hopa this will be of use to people:

In my form I have a SELECT named user[list], and the line
 {:action =&#62; 'updateform'}, :with =&#62; 'id' %&#62;

The trick is the :with =&#62; 'id', to tell the subsequent what to map the select's value to.

In the controller, the "updateform" action simply reads:
@user = User.find(params[:id])

And finally, the "updateform.rjs" consists of:
page.replace_html 'formpartial', :partial =&#62; 'form', :object =&#62; @user

Which automagically repaints the form (which itself is a partial) with the values for the @user object.

This may be old hat for a lot of people, but I have been cruising the net for three days looking for this solution. So again: hope this helps someone!

Best,
Johan</description>
		<content:encoded><![CDATA[<p>At last! Excuse my incessant ranting, but I hopa this will be of use to people:</p>
<p>In my form I have a SELECT named user[list], and the line<br />
 {:action =&gt; &#8216;updateform&#8217;}, :with =&gt; &#8216;id&#8217; %&gt;</p>
<p>The trick is the :with =&gt; &#8216;id&#8217;, to tell the subsequent what to map the select&#8217;s value to.</p>
<p>In the controller, the &#8220;updateform&#8221; action simply reads:<br />
@user = User.find(params[:id])</p>
<p>And finally, the &#8220;updateform.rjs&#8221; consists of:<br />
page.replace_html &#8216;formpartial&#8217;, :partial =&gt; &#8216;form&#8217;, <img src='http://nealenssle.com/blog/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> bject =&gt; @user</p>
<p>Which automagically repaints the form (which itself is a partial) with the values for the @user object.</p>
<p>This may be old hat for a lot of people, but I have been cruising the net for three days looking for this solution. So again: hope this helps someone!</p>
<p>Best,<br />
Johan
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
