Hi Damon,
Do you have some code to show? That would make things a bit easier to
comment on…
Best regards,
torben
Hi Damon,
Do you have some code to show? That would make things a bit easier to
comment on…
Best regards,
torben
Torben–
Thanks for the reply.
I do have some code that I posted yesterday in another thread, but would
love to post here again for you
Main View
Controller
def get_customer_address
form_customer_id = params[:customer_id]
@found_customer = Customer.find(form_customer_id)
end
def get_customer_credit_limit
form_customer_id = params[:customer_id]
@found_customer_limit = Customer.find(form_customer_id)
end
Returning Views
get_customer_address.rhtml
<%= text_field(“purchase_order”, “customer_address”, :readonly =>
“readonly”, “size” => 25, :value => @found_customer.address) %>
<%= text_field(“purchase_order”, “customer_city”, :readonly =>
“readonly”,
“size” => 10, :value => @found_customer.city) %>
<%= text_field(“purchase_order”, “customer_state”, :readonly =>
“readonly”,
“size” => 2, :value => @found_customer.state) %>
<%= text_field(“purchase_order”, “customer_postal_code”, :readonly =>
“readonly”, “size” => 5, :value => @found_customer.postal_code) %>
get_customer_credit_limit.rhtml
<%= text_field(“purchase_order”, “customer_credit_limit”, :readonly =>
“readonly”, :value => @found_customer_limit.credit_limit) %>
Thanks!
~damon
Hi Damon
I can’t say that I have tried the thing you want, but I had a look in
the “Agile Development”-book that holds a tip I think might be usable.
The tip goes, that you return a bunch of generated javascript that you
evaluate in the client.
So, you will do something like:
observe_field(:purchase_order_customer_id,
:complete => “eval(request.responseText)”,
:url => { :action => :get_all_customer_info },
:with => “‘customer_id=’+escape(value)”)
In the template, you generate the javascript that updates all the
fields:
document.getElementById(“po_customer_address”).value = ‘<%=
@found_customer.address %>’;
document.getElementById(“po_credit_limit”).value = ‘<%=
@found_customer_limit.credit_limit %>’;
and so on.
Hope this helps…
Torben
El Jueves 17 Noviembre 2005 19:20, Torben
Wölm escribió:> observe_field(:purchase_order_customer_id,
@found_customer_limit.credit_limit %>';
I think that you have an “update_element_function”[1] to do such a
thing.
Good luck!
[1]
http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#M000430
–
o) Imobach González Sosa
//\ email: imobachgs at step dot es
V/_ jid: osoh at jabberes dot org
url: banot.net - banot Resources and Information.
blog: http://devnull.blogs.banot.net/
–
Este mensaje ha sido analizado por STEP On Line
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio. 902 10 18 43
I think that you have an “update_element_function”[1] to do such a thing.
Good luck!
Ahh - sweet. The documentation even holds an example of – how to make
multiple updates!
Thanks,
Torben
Thanks for the replies Torben and Imobach.
I did attempt to implement the update_element_function however, the
action
it was looking for was an onSubmit() and I need the form to update on an
onEvent() action.
I will look again and see if there is a way to set which action the
update_element_function looks for.
Thanks again,
~damon
Solved!!!
The examples and hints given by Torben worked beautifully! Thanks!
Here is my view now:
<%= observe_field(:purchase_order_customer_id,
:complete => “eval(request.responseText)”,
:url => { :action => :get_customer_info },
:with => “‘customer_id=’+escape(value)”)%>
My controller just finds the specified customer record designated by
customer_id.
Then the get_customer_info.rhtml looks like this:
document.getElementById(“po_customer_address”).value = ‘<%=
@found_customer.address %>’;
document.getElementById(“po_customer_city”).value = ‘<%=
@found_customer.city %>’;
document.getElementById(“po_customer_state”).value = ‘<%=
@found_customer.state %>’;
document.getElementById(“po_customer_postal_code”).value = ‘<%=
@found_customer.postal_code %>’;
document.getElementById(“po_credit_limit”).value = ‘<%=
@found_customer.credit_limit %>’;
document.getElementById(“po_current_balance”).value = ‘<%=
@found_customer.inv_balance %>’;
Thanks again!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs