Ajax listener and partials

Folks,

I have a shopping cart app that asks users for their shipping address,
and then asks them to click a checkbox if they have a different billing
address. There’s an event listener on the checkbox that detects the
click and renders a partial containing a series of new form fields for
the billing address. Works fine. Except that the user input in the
billing address fields isn’t being captured in params or saved to the
model. I have an app w/ identical functionality to this that works
fine, and I can’t figure out what’s going wrong. I’d be grateful for
any suggestions.

main view

<%= form_tag({:action => ‘save_customer’}, :multipart => true) %>
<%= javascript_include_tag ‘prototype’ %>

Please enter your details below

Name
<%= text_field("customer", "name", "size" => 40 ) %>
Your e-mail address
<%= text_field("customer", "email", "size" => 40 ) %>

Your shipping address

<%= text_field(“customer”, “ship_address1”, “size” => 40 ) %>

Address line 2
<%= text_field("customer", "ship_address2", "size" => 40 ) %>
City
<%= text_field("customer", "ship_city", "size" => 40 ) %>
State
<%= options = [["Select a state", ""]] + Customer::STATE_NAMES select("customer", "ship_state", options) %>
Zipcode
<%= text_field("customer", "ship_zip", "size" => 10 ) %>
Country
<%= options = [["Select a country", ""]] + Customer::COUNTRY_NAMES select("customer", "ship_country", options) %>
Check if you have a different billing address

<%= check_box_tag(“different_bill”) %>

<%= observe_field(:different_bill, :update => “billinfo”, :url => {
:controller=>‘shirts’, :action => ‘billing_address’ }, :with =>
“‘id=’+value” ) %>

Payment method
Credit CardPaypal

<%= submit_tag "Save" %>
<%= end_form_tag %>

partial – _billinfo.rhtml

Your billing address

<%= text_field(“customer”, “bill_address1”, “size” => 40 ) %>

Address line 2
<%= text_field("customer", "bill_address2", "size" => 40 ) %>
City
<%= text_field("customer", "bill_city", "size" => 40 ) %>
State
<%= options = [["Select a state", ""]] + Customer::STATE_NAMES select("customer", "bill_state", options) %>
Zipcode
<%= text_field("customer", "bill_zip", "size" => 10 ) %>
Country
<%= options = [["Select a country", ""]] + Customer::COUNTRY_NAMES select("customer", "bill_country", options) %>

controller action

def billing_address
  if  params[:id] == "1"
  render :partial => 'billinfo', :layout => false
 else
    render :nothing=>true
 end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs