I used link-to-remote to update the Cart part in my Product page.
Since I wanted to allow submitting Amount, I tried moving to a form
and use 'update="carting"' instead. for some reason it doesn't work.
when I try it, the spinner displays but nothing change on the page
(the product seem to be in the cart but I need to reload the entire
page to see this)
my original link-to-remote:
<%= link_to_remote( "הוסף לעגלה",
{:update => "carting",
:loading => "Hobo.showSpinner('מעדכן עגלה');",
:complete => "Hobo.hideSpinner();",
:url => { :action => :add_to_cart, :id => this_parent }},
{:class => 'buy-button'}) %>
my updated form:
<form for="&this" action="products/add_to_cart" update="#"
method="POST">
<input name="id" value="&this_parent.id" type="hidden"/>
<input type="text" name="amount" title="כמות" value="1"
size="2"/>
<submit label="הוסף לעגלה"/>
</form>
my cart div:
<div id="carting" part="cart">
<partial name="cart" locals="&{:cart => @cart}"/>
</div>
the server log for my original link-to-remote:
Processing ProductsController#add_to_cart (for 127.0.0.1 at 2009-09-04
22:41:59) [POST]
Parameters: {"id"=>"6831-"}
Cart Load (0.3ms) SELECT * FROM `carts` WHERE (`carts`.`id` = 22)
Product Load (0.3ms) SELECT * FROM `products` WHERE
(`products`.`id` = 6831)
CartItem Load (0.3ms) SELECT * FROM `cart_items` WHERE
(`cart_items`.`product_id` = '6831-') AND (`cart_items`.cart_id = 22)
CACHE (0.0ms) SELECT * FROM `products` WHERE (`products`.`id` =
6831)
SQL (0.1ms) BEGIN
CartItem Create (0.3ms) INSERT INTO `cart_items` (`updated_at`,
`price`, `product_id`, `amount`, `cart_id`, `created_at`) VALUES
('2009-09-04 19:41:59', 288.0, 6831, 1, 22, '2009-09-04 19:41:59')
SQL (0.5ms) COMMIT
CartItem Load (0.4ms) SELECT * FROM `cart_items` WHERE
(`cart_items`.cart_id = 22)
Product Load (0.4ms) SELECT * FROM `products` WHERE
(`products`.`id` = 6831)
Rendered products/_cart_item (348.7ms)
Rendered products/_cart (555.2ms)
Completed in 578ms (View: 556, DB: 68) | 200 OK [http://0.0.0.0/
products/add_to_cart/6831-]
and the server log for the form:
Processing ProductsController#add_to_cart (for 127.0.0.1 at 2009-09-04
22:42:31) [POST]
Parameters: {"page_path"=>"products/index", "render"=>{"0"=>
{"id"=>"carting", "part_context"=>"BAhbCDoJY2FydCIJdGhpc1sA--
d99f2884fd6537dc5f241ddf4e2b44d2cd65c2dd\n"}}, "id"=>"6831",
"amount"=>"1", "_"=>""}
Cart Load (0.3ms) SELECT * FROM `carts` WHERE (`carts`.`id` = 22)
Product Load (0.3ms) SELECT * FROM `products` WHERE
(`products`.`id` = 6831)
CartItem Load (0.3ms) SELECT * FROM `cart_items` WHERE
(`cart_items`.`product_id` = '6831') AND (`cart_items`.cart_id = 22)
CACHE (0.0ms) SELECT * FROM `products` WHERE (`products`.`id` =
6831)
SQL (0.1ms) BEGIN
CartItem Create (0.3ms) INSERT INTO `cart_items` (`updated_at`,
`price`, `product_id`, `amount`, `cart_id`, `created_at`) VALUES
('2009-09-04 19:42:31', 288.0, 6831, 1, 22, '2009-09-04 19:42:31')
SQL (0.6ms) COMMIT
CartItem Load (0.4ms) SELECT * FROM `cart_items` WHERE
(`cart_items`.cart_id = 22)
Product Load (0.4ms) SELECT * FROM `products` WHERE
(`products`.`id` = 6831)
Rendered products/_cart_item (217.8ms)
Rendered products/_cart (560.7ms)
Completed in 583ms (View: 561, DB: 74) | 200 OK [http://0.0.0.0/
products/add_to_cart]
there are only two differences, and I don't exactly know how to change
the form so it'll work closer to the link-to-remote (or change the
link-to-remote so it'll take the amount).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---