Browse Source

Iteration F4.

master
Nils Dittberner 9 years ago
parent
commit
62852285b7
4 changed files with 12 additions and 4 deletions
  1. +1
    -1
      app/controllers/carts_controller.rb
  2. +6
    -0
      app/helpers/application_helper.rb
  3. +3
    -3
      app/views/layouts/application.html.erb
  4. +2
    -0
      app/views/line_items/create.js.erb

+ 1
- 1
app/controllers/carts_controller.rb View File

@@ -59,7 +59,7 @@ class CartsController < ApplicationController
@cart.destroy if @cart.id == session[:cart_id]
session[:cart_id] = nil
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 }
end
end


+ 6
- 0
app/helpers/application_helper.rb View File

@@ -1,2 +1,8 @@
module ApplicationHelper
def hidden_div_if(condition, attributes = {}, &block)
if condition
attributes["style"] = "display: none"
end
content_tag("div", attributes, &block)
end
end

+ 3
- 3
app/views/layouts/application.html.erb View File

@@ -15,11 +15,11 @@
</div>
<div id="columns">
<div id="side">
<div id="cart">
<% if @cart %>
<% if @cart %>
<%= hidden_div_if(@cart.line_items.empty?, id: 'cart') do %>
<%= render @cart %>
<% end %>
</div>
<% end %>

<ul>
<li><a href="/">Home</a></li>


+ 2
- 0
app/views/line_items/create.js.erb View File

@@ -1,3 +1,5 @@
if ($('#cart tr').length == 1) { $('#cart').show('blind', 1000); }

$('#cart').html("<%=j render(@cart) %>")

$('#current_item').css({'background-color':'#88ff88'})


Loading…
Cancel
Save