diff --git a/ko-cart/index.html b/ko-cart/index.html index 1c0561b..f4c56b8 100644 --- a/ko-cart/index.html +++ b/ko-cart/index.html @@ -7,12 +7,16 @@
-
+
- + +
+ -
diff --git a/ko-cart/js/viewmodel.js b/ko-cart/js/viewmodel.js index 128c856..810640c 100644 --- a/ko-cart/js/viewmodel.js +++ b/ko-cart/js/viewmodel.js @@ -44,7 +44,7 @@ var vm = (function () { var cart = ko.observableArray([]); var showCartDetails = function () { if (cart().length > 0) { - $("#cartContainer").removeClass("hidden"); + visibleCart(true); } }; var addToCart = function(data) { @@ -94,17 +94,15 @@ var vm = (function () { // The cart template var hideCartDetails = function() { - $('#cartContainer').addClass("hidden"); + visibleCart(false); }; var showOrder = function () { - $('#catalogContainer').addClass("hidden"); - $('#orderContainer').removeClass("hidden"); + visibleCatalog(false); } // The order template var showCatalog = function () { - $("#catalogContainer").removeClass("hidden"); - $("$orderContainer").addClass("hidden"); + visibleCatalog(true); }; var finishOrder = function() { cart([]); @@ -113,6 +111,9 @@ var vm = (function () { $("#finishOrderModal").modal('show'); } + var visibleCatalog = ko.observable(true); + var visibleCart = ko.observable(false); + return { // first chapter searchTerm: searchTerm, @@ -128,7 +129,9 @@ var vm = (function () { hideCartDetails: hideCartDetails, showOrder: showOrder, showCatalog: showCatalog, - finishOrder: finishOrder + finishOrder: finishOrder, + visibleCatalog: visibleCatalog, + visibleCart: visibleCart }; })(); ko.applyBindings(vm);