here is the rhtml that works:

<% if cart_item == @current_item %>
  <tr id="current_item">
<% else %>
  <tr>
<% end %>
  <td><%= cart_item.quantity %>×</td>
  <td><%= h(cart_item.title) %></td>
  <td class="item-price"><%= number_to_currency(cart_item.price) %></
td>
  <td>
     <%= link_to_remote "-", {:url => { :action
=> :remove_from_cart, :id => cart_item.product}},
       { :href => url_for(:action => :remove_from_cart, :id =>
cart_item.product) }  %> 
     <%= link_to_remote "+", {:url => { :action => :add_to_cart, :id
=> cart_item.product}},
       { :href => url_for(:action => :add_to_cart, :id =>
cart_item.product) }  %>
  </td>
</tr>

here is the rjs that works with the rhtml:

=begin
rjs doesn't give us the ability to generate JavaScript that tests
for divs. It does, however, let us iterate over elements on the page
that match
a certain CSS selector pattern.
=end
page.select("div#notice" ).each { |div| div.hide }
page.replace_html("cart", :partial => "cart", :object => @cart)
page.replace_html("flash_notice", "<div></div>")

#START_HIGHLIGHT
page[:cart].visual_effect :blind_down if @cart.total_items ==
1
#END_HIGHLIGHT

page[:current_item].visual_effect :highlight,
                                  :startcolor => "#88ff88",
                                  :endcolor => "#114411"

here is the haml:

- if cart_item == @current_item
  %tr#current_item
- else
  %tr
    %td
      = cart_item.quantity
      ×
    %td
      = h(cart_item.title)
    %td{:class => 'item-price'}
      = number_to_currency(cart_item.price)
    %td
      = link_to_remote "-", {:url => {:action
=> :remove_from_cart, :id => cart_item.product}}, {:href =>
url_for(:action => :remove_from_cart, :id => cart_item.product)}
       
      = link_to_remote "+", {:url => {:action => :add_to_cart, :id =>
cart_item.product}}, {:href => url_for(:action => :add_to_cart, :id =>
cart_item.product)}


here is the 'section' in the nav (store.rhtml)

      <% hidden_div_if(@cart.items.empty?, :id => "cart") do %>
        <%= render(:partial => "cart", :object => @cart) %>
      <% end %>

partial for the 'cart' (haml -- this renders and works with the rhtml
version of the + -)

%div{:class => 'cart-title'} Your Cart
%table
  = render(:partial => "cart_item", :collection => cart.items)

  %tr{:class => 'total-line'}
    %td{:colspan => '2'} Total
    %td{:class => 'total-cell'}
      =number_to_currency(cart.total_price)
    %td
- if @order.nil?
  = button_to("Checkout" , :action => :checkout)
  - form_remote_tag :url => { :action => :empty_cart } do
    = submit_tag("Empty cart")

-Don



*********************************************************************************************************************

when running the rhtml and pressing the '+' or '-' in the window, it
will add the item (or remove) the item and inc/dec the item count.  It
will then 'flash' to let the user 'know' something changed.

when I use the haml version, it executes, but the update will 'hide'
or change the view.  If I 'refresh' the form, the items show up and
show up with the 'correct' values.

-Don

' values.

-Don


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" 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/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to