Allen Walker wrote:
> I have the following in my view:
> 
> <%= observe_field 'guarantee_status', :url => {:controller =>
> 'testcontroller', :action => 'change_status'}, :with => 'value' %>
> <div id="balance_div" style="display:none">
>   <p>
>     <b>Remaining Balance</b>
>     <%= f.text_field :balance %>
>   </p>
> </div>
> 
> No when I first load this page, I need the change_status method hit on
> my controller. It's only hit if I actually change the "guarantee_status"
> field.
> 
> here's the method in my controller:
> 
> def change_status
>     if request.xhr?
>       render :update do |page|
>         if params[:value].blank? || params[:value] == 'Due'
>           page[:balance_div].hide
>         else
>           page[:balance_div].show
>         end
>       end
>     end
>   end

One way is to add the following below balance_div:

<%= javascript_tag "$('guarantee_status').onchange()" %>

Another would be to only render display:none into the
div tag if the condition is met.

The first method is preferred because when a page is
refreshed in Firefox it does not reset form entries,
but your app is still called as a simple GET, so the
div may be inappropriately made visible or hidden.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to