I’ve been playing with the new RJS stuff in RoR1.1, and I have to say
that I’m am extremely impressed, NICE! work guys. However, I seem to be
having a bit of a problem. I promise, I’ve googled the hell out of it
and haven’t found an answer.
Set up: Putting together a little proof of concept app. Display a form
(index.rhtml) that just has a button to call the next action
(show_admin_conf). Have created a show_admin_conf.rjs and the
show_admin_conf method is actually empty. When it goes to the
show_admin_conf.rjs I’m just asking it to hide a
id. What I get is the
content area where I’m trying to update (not related to
be pulling up a new partial in show_admin_conf.rhtml.
the controller code
class AbeProto1Controller < ApplicationController
def index
end
def show_conf_admin
end
def conf_admin
render( :partial => “conf_net”)
end
end
The index.rhtml:
<%=
javascript_tag(“document.getElementById(‘index’).className=‘selected’;”)
%>
<%= form_remote_tag(:url => { :action => “show_conf_admin” }, :update =>
“main”) %>
<div id="main_content">
-no content-
</div> <!-- main_content -->
<div id="main_options">
Press Begin to start.
<div id="main_buttons">
<%= submit_tag("Begin!") %>
</div> <!-- main_buttons -->
</div> <!-- main_options -->
<%= end_form_tag %>
the show_admin_conf.rjs (in same directory as my rhtml files)
page[‘index’].hide
puts “ONE”
render(:partial => ‘conf_admin’, :update => ‘main’)
puts “TWO”
And, finally, the _conf_admin.rhtml partial:
<%=
javascript_tag(“document.getElementById(‘conf_admin’).className=‘selected’;”)
%>
<%= form_remote_tag(:url => { :action => “conf_admin” },
:update => "main") %>
<div id="main_content">
-no content-
</div> <!-- main_content -->
<div id="main_options">
Press Next to continue.
<div id="main_buttons">
<%= submit_tag("Next") %>
</div> <!-- main_buttons -->
</div> <!-- main_options -->
<%= end_form_tag %>
The div id “main” defined in my template (not really interesting, so not
included) is where the index.rhtml and _conf_admin.rhtml are supposed to
render.
Ok, now, here’s what I’m getting, and ALL I’m getting in my “main” div:
$(“index”).hide();
Which is correct. . .sort of. It DOES hide the index object correctly,
but displays the above in the div and does not show my partical in the
“main” div.
Been working on this for about 24 hours, most of that spent googling and
reading over everybody’s examples (again, and again, and again : b).
Any help would be GREATLY appreciated. I know something silly is going
on here, but for the life of me I can’t figure out what.
Thanks!
Gerald