It seems I have this working using the approach of rendering all of the 
partials and then hiding/displaying the div as needed.  I was able to 
get this to partially work in the past with an RJS file using Marnen's 
suggestion of using a separate form builder within each of the partials. 
This was done to address the fact that I couldn't pass the form object 
through the observe_field method.

Unfortunately, with this current approach I have the same issue I had 
when I got it working with the RJS file. This remaining issue is that 
when a validation error occurs, teh partial is getting cleared. I'm not 
sure why.  If I do a simple reload/refresh on the browser, the values 
within the partials are preserved, but not when a validation error 
occurs.

Any thoughts on what the validation may be doing that clears the dynamic 
partial? Do you think the validation errors cause a re-rendering of the 
partials even though a page reload/refresh does not?

here is some of the code...

==============Form the main form page .html.erb =============
.
.
.
    <div id="partial1" style="display: none;">
      <%= render "partial1" %>
    </div>
    <div id="partial2" style="display: none;">
      <%= render "partial2"  %>
    </div>
    <div id="partial3" style="display: none;">
      <%= render 'partial3', :w => f  %>
    </div>

    <%= javascript_tag "set_section_two();" %>

===== application .js file ================

function set_section_two() {
  var team=document.getElementById("trial_org_id").value;
  hide_all_dynamic_divs()
  //alert('set_section_two() called');
  switch(team)
  {
    case '1':
      $('partial1').style.display = 'block';
    break;
    case '2':
      $('partial2').style.display = 'block';
    break;
    case '3':
      $('partial3').style.display = 'block';
    break;
    default:
//      alert('other');
    break;
  }

}
function hide_all_dynamic_divs(){
  $('partial1').style.display = 'none';
  $('partial2').style.display = 'none';
  $('partial3').style.display = 'none';
}




-- 
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-t...@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