Rendering partials with ajax checkbox/observer

I decided to create an advanced search form which is stored in a partial called:

_search.html.erb

Right now the partial just contains a simple two box nested form_tag..

In my index.html I have the following:

<% form_tag controller.controller_path, :method => 'get' do %>   Advanced Search   <%= check_box "search", "info" %>   <%= observe_field(:search_info,     :on=>'click',     :frequency=>0.25,     :update => :submit_div,     :with => :search_info,     :url => { :action => :search_form }) %>   <div id="submit_div">   </div> <% end -%>

Which basically monitors the search_info from the check_box and when it hits an event onClick it goes to the search_form method specified in my controller, updating :search_info..

So, in my controller I tested all of the returns:

def search_form   validate_date_form   if params[:search_info] == "null"     #render :text => ""     render :text => "Debug search_info unchecked = " + params[:search_info]   else     #render :partial => "search"     render :text => "Debug search_info checked = " + params[:search_info]   end end

When I fire up my page, if I click the checkbox I receive:

Debug search_info checked = "1"

If I uncheck the checkbox I receive:

Debug search_info unchecked = "null"

If I comment out the debug lines and uncomment what's listed above the following occurs:

Firefox:

If I check the box the partial is rendered. If I uncheck the box, the partial is removed.

Internet Explorer:

If I check the box, nothing happens. If I uncheck the box, I can see a slight buffer from the empty div showing so the "null" is accepted.

Why is the partial not rendering in I.E.?

If I comment out the debug lines and uncomment what's listed above the following occurs:

Firefox:

If I check the box the partial is rendered. If I uncheck the box, the partial is removed.

Internet Explorer:

If I check the box, nothing happens. If I uncheck the box, I can see a slight buffer from the empty div showing so the "null" is accepted.

Why is the partial not rendering in I.E.?

Looks like your html will be invalid (so browsers can do what they want), as when your partial is rendered you'll end up with a form nested inside a form (at least that's my reading of your code)

Fred

Update:

Firefox 3.5 => partial renders OK Opera 9.6.4 => partial renders OK Safari 4.0 => partial renders OK

Internet Explorer 8 => partial does not render