| @@ -59,7 +59,7 @@ class CartsController < ApplicationController | |||||
| @cart.destroy if @cart.id == session[:cart_id] | @cart.destroy if @cart.id == session[:cart_id] | ||||
| session[:cart_id] = nil | session[:cart_id] = nil | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.html { redirect_to store_index_url, notice: 'Your cart is currently empty.' } | |||||
| format.html { redirect_to store_index_url } | |||||
| format.json { head :no_content } | format.json { head :no_content } | ||||
| end | end | ||||
| end | end | ||||
| @@ -1,2 +1,8 @@ | |||||
| module ApplicationHelper | module ApplicationHelper | ||||
| def hidden_div_if(condition, attributes = {}, &block) | |||||
| if condition | |||||
| attributes["style"] = "display: none" | |||||
| end | |||||
| content_tag("div", attributes, &block) | |||||
| end | |||||
| end | end | ||||
| @@ -15,11 +15,11 @@ | |||||
| </div> | </div> | ||||
| <div id="columns"> | <div id="columns"> | ||||
| <div id="side"> | <div id="side"> | ||||
| <div id="cart"> | |||||
| <% if @cart %> | |||||
| <% if @cart %> | |||||
| <%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %> | |||||
| <%= render @cart %> | <%= render @cart %> | ||||
| <% end %> | <% end %> | ||||
| </div> | |||||
| <% end %> | |||||
| <ul> | <ul> | ||||
| <li><a href="/">Home</a></li> | <li><a href="/">Home</a></li> | ||||
| @@ -1,3 +1,5 @@ | |||||
| if ($('#cart tr').length == 1) { $('#cart').show('blind', 1000); } | |||||
| $('#cart').html("<%=j render(@cart) %>") | $('#cart').html("<%=j render(@cart) %>") | ||||
| $('#current_item').css({'background-color':'#88ff88'}) | $('#current_item').css({'background-color':'#88ff88'}) | ||||