From 46f7972285845bdf964edbf7ce9f0a1747ab0c4c Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Fri, 28 Dec 2012 16:31:47 -0300 Subject: [PATCH] Move JS code out of HTML template --- plugins/shopping_cart/public/cart.js | 15 ++++++++++++++- plugins/shopping_cart/views/cart.html.erb | 19 ------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/plugins/shopping_cart/public/cart.js b/plugins/shopping_cart/public/cart.js index 9a07283..b65941d 100644 --- a/plugins/shopping_cart/public/cart.js +++ b/plugins/shopping_cart/public/cart.js @@ -309,7 +309,20 @@ function Cart(config) { } $(function(){ - $('.cart-add-item').button({ icons: { primary: 'ui-icon-cart'} }) + + var profile = 'foo'; // FIXME + $.ajax({ + url: "/profile/" + profile + "/plugin/shopping_cart/get", + dataType: 'json', + success: function(data) { + new Cart(data); + $('.cart-add-item').button({ icons: { primary: 'ui-icon-cart'} }) + }, + cache: false, + error: function(ajax, status, errorThrown) { + alert('Error getting shopping cart - HTTP '+status+': '+errorThrown); + } + }); }); })(jQuery); diff --git a/plugins/shopping_cart/views/cart.html.erb b/plugins/shopping_cart/views/cart.html.erb index f39af37..922f763 100644 --- a/plugins/shopping_cart/views/cart.html.erb +++ b/plugins/shopping_cart/views/cart.html.erb @@ -15,22 +15,3 @@ - - -- libgit2 0.21.2