Hi - another question, sorry....
I''m trying to get the highlighting effect to work on the current_item.
The page refreshes fine, and then I get an error as the highlighting
code is fired:
page[:current_item].visual_effect :highlight,
:startcolor => "#88ff88",
:endcolor => "#114411"
The error is: RJS Error [object Error] (which is helpful!)
Followed by a pop up window containing the page code, the last line of
which is:
$("current_item").visualEffect("highlight",
{"startcolor":"#88ff88",
"endcolor":"#114411"});
Code in cart.rb:
# add a product to the cart
def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
current_item.increment_quantity
else
current_item = CartItem.new(product)
@items << current_item
end
current_item
end
Code in storecontroller.rb:
# add a product to the cart
def add_to_cart
begin
@product = Product.find(params[:id])
rescue
logger.error("Attempt to access invalid product #{params[:id]}")
redirect_to_index("Invalid product")
else
@cart = find_cart
@current_item = @cart.add_product(@product)
end
end
Code in _cart_item.rhtml:
<% 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"><%= format_price(cart_item.price)
%></td>
</tr>
What is it that I can''t see!?
--
Posted via http://www.ruby-forum.com/.