Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
help with action for update
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dark Ambient  
View profile  
 More options Sep 10 2006, 8:00 am
From: "Dark Ambient" <sambi...@gmail.com>
Date: Sun, 10 Sep 2006 06:00:01 -0600
Local: Sun, Sep 10 2006 8:00 am
Subject: help with action for update
I'm working on setting up a form where one element gets updated
depending on what value was checked in another element.  Sadly though
I'm not sure exactly what to do with my controller action and if i'll
need to depend on form_tag_remote. I do want the element updated
before submit so probably not needing the form_tag call.

So far my view looks like this:

<%=
@pays = Pay.find(:all, :order => "id").map {|p| [p.name, p.id] }
select(:pay, :name, @pays) %>

<span id="wagespec"><%=
@wages = Wage.find(:all, :order => "id").map {|p| [p.name, p.id] }
select(:wage, :name, @wages, {},{:disabled => true}) %>
</span>

<%= observe_field("pay[id]",
  :frequency => 0.25,
  :update => "wagespec",
  :url => {:action => :get_wages},
  :with => "'pay_id='+value")
%>

So I need to create an action called get_wages that will enable and
update @wages.  Are there special calls to accomplish this ?

TIA
Stuart


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dark Ambient  
View profile  
 More options Sep 10 2006, 12:02 pm
From: "Dark Ambient" <sambi...@gmail.com>
Date: Sun, 10 Sep 2006 10:02:45 -0600
Local: Sun, Sep 10 2006 12:02 pm
Subject: Re: help with action for update
Updating this thread. First is 3 days on the same problem unusual or
an indication not to give up my day job ?

Okay, I'm still trying to do a dynamic drop down based on user choice
in first select.
I came across this post -
http://www.ruby-forum.com/topic/61521
and translating to my setup , so far it's not working , then again no
errors in log or debug.

First, I have two tables/model  'pay' with an id and name, and wage
with an id, pay_id, and name.

When user choose pay, I want to take the id of the pay selection and
update, or load partial from wage select.

Using the example above I created the following files:

#view
<p><label for="pay">Pay Type</label><br/>
<select id="pay[id] name="pay[id]">
  <%= options_from_collection_for_select(
   Pay.find_all, "id", "name") %>
</select></p>

<span id="wage_list">
<label for="wage">Wage specifics</label><br/>
  <select id="wage[pay_id]" name="wage[pay_id]"></select>
</span>

<%= observe_field("pay[id]",
    :frequency  => 0.0,
    :update => "wage_list",
    :url => {:action => :fill_wages},
    :with => "'wage[pay_id]='+value") %>

#controller method
  def fill_wages
    @lookups = Lookup.find_all_by_list_prompt(@params[:wage], :order
=> 'pay_id')
    render  :partial => 'wagespecs'
  end

I also created _wagespecs though Im not entirely sure what goes in
there since the example above didn't show it .

Anyone give me some help on this ?
Stuart

On 9/10/06, Dark Ambient <sambi...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stef T  
View profile  
 More options Sep 10 2006, 1:43 pm
From: Stef T <s...@ummon.com>
Date: Sun, 10 Sep 2006 13:43:11 -0400
Local: Sun, Sep 10 2006 1:43 pm
Subject: Re: [Rails] Re: help with action for update

Hello "Dark" (strange first name, but, hey, thats what makes the world
go round* ;)
    I do something similiar to what your asking, except I use Agent's
and their currency. The quirk comes that if an agent only has one
currency, then it shouldn't even offer a select box, but rather default
to the single currency. Here is how I do it, you can take from it what
you want (or not, your choice ;);

    views/booking/new.html

    <p/>
        <% agent_change_ajax = remote_function(:update => :currencyList,
                    :url  => { :controller => 'agent', :action =>
:list_currency_ajax_search },
                    :with => "'agentid='+value")
        %>
        <label for="booking_agent">The Agent for this Booking is : </label>
        <%= select('booking', 'agent', Agent.default_quickbook_options,
{ :selected => 2828 }, { :onchange => agent_change_ajax }) %>

    <p/>
    <div id="currencyList">
        <label for="booking_currency">Which Currency should this Booking
be made in : </label>
        <!-- setup the default currency for the first pass //-->
        <%= select('booking', 'currency', Currency.currency_options, {
:selected => 2 }) %>
    </div>

    controllers/agent_controller.rb

    def list_currency_ajax_search
        myAgent = Agent.find(params['agentid'])
        @currencies = myAgent.currency # obtained by the model Agent
having a relation to currencies
        render(:layout=>false,:partial => 'list_currency_ajax_search')
    end

    views/agent/_list_currency_ajax_search.rhtml

<% if @currencies.size == 1 %>
    <input type="hidden" id="booking_currency" name="booking[currency]"
value="<%= @currencies.
first.currency_id %>" />
    <label for="booking_currency">Agent only accepts <%=
@currencies.first.iso_code %> </label>
<% else %>
    <label for="booking_currency">Which Currency should this Booking be
made in : </label>
    <select id="booking_currency" name="booking[currency]">
        <option value="" selected="selected">Please Select One</option>
        <% for currency in @currencies do -%>
            <option value="<%= currency.id %>"><%= currency.iso_code
%></option>
        <% end -%>
    </select>
<% end %>

    Hopefully, you should get an idea of what to do from this. I would
say having an 'onchange' is better than having a constantly polling
observer, but, I am not 1000% sure that observe_field does what I think
it does. Eh. ymmv ':)

    Regards
    Stef
(* apparently so does ; love, money, sex and rock n roll)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »