Elliott Golden wrote:
> Since I am not rendering an rjs template what would this be? I just
> want the show.html.erb template to draw out in its entirety.
> 
> Thanks

<%= select(:state, :state, [['Alabama', 'AL'], ... ['Wyoming',
'WY']], {},
  html_options = {:onchange => remote_function(:url => {:action =>
"new", :id => 74}, :with => "'state_test='+this.value", :method
=> :get)} )
%>

This is the first time I've seen the remote_function method but this is 
what I think is happening.  Your code creates an html <select> tag.  The 
html_options variable is used to write attributes into the <select> tag, 
e.g.

<select id="hello" class="cool_css" onchange="javascript function call">

So your code adds an onchange attribute to the <select> tag, which calls 
a javascript function.  You've also given the particulars for the 
javascript function to construct a request to send to the server when 
the javascript function gets called.  Then the server will send the 
results back to the javascript function.   So you need to tell the 
javascript function where you want the results to be inserted on the 
page.  Javascript doesn't automatically do anything with the results. 
That is what the :update parameter for remote_function does--it tells 
the javascript function what to do with the results, i.e. insert the 
results in the specified tag.

> I just want the show.html.erb template to draw out in its entirety.

So you want to replace the whole page?  What if you specified the id of 
the <body> tag?  If all the layout stuff gets added to the template, I 
don't think that will work--you'd end up with another DOCTYPE tag, etc. 
inside the <body> tag making your html a mess.

In addition, when you need to replace the whole page, you don't use 
javascript to make an ajax request to the server.  It sounds like you 
need something like the following inside your <select> tag:

<select onchange="window.location.href = '/show?id=74&state_test=' + 
this.value ">

I'm a beginner, so I don't know if rails can do that for you.  You might 
have to write that by hand doing something like this:

<%= select(:state, :state, [['Alabama', 'AL'], ... ['Wyoming',
'WY']], {},

html_options =
{
:onchange => "window.location.href = '/show?id=74&state_test=' + 
this.value "
}

%>
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to