From d6e896dd752b13c8f8a098da1cf325f1be14e23f Mon Sep 17 00:00:00 2001 From: Brett Costabile Date: Thu, 14 Apr 2016 23:06:41 -0400 Subject: [PATCH] Fixed some JS issues Didn't search for classes correctly --- static/js/orders.js | 15 ++++++++------- static/js/stock.js | 28 +++++++++++++++------------- templates/public/orders.html | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/static/js/orders.js b/static/js/orders.js index 4220df7..f2f55fa 100644 --- a/static/js/orders.js +++ b/static/js/orders.js @@ -2,25 +2,26 @@ var orderModal = $('#newOrderModal') var orderForm = $('#orderForm'); $( document ).ready( orderForm.submit(function() { + orderModal.find(".modalResponse").first().empty().attr('class','modalResponse'); $.ajax({ type: orderForm.attr('method'), url: orderForm.attr('action'), data: orderForm.serialize(), success: function(data) { - orderModal.modal('hide') - location.reload() + orderModal.modal('hide'); + location.reload(); }, error: function(data) { - $("#orderModalResponse").empty().append('×') - $("#orderModalResponse").append(data.responseText) - $("#orderModalResponse").addClass("alert alert-danger fade in"); + orderModal.find(".modalResponse").first().empty().append('×'); + orderModal.find(".modalResponse").first().append(data.responseText); + orderModal.find(".modalResponse").first().addClass("alert alert-danger fade in"); } }); return false; }), - $("modal").each( function() { + $(".modal").each( function() { $(this).on('hidden.bs.modal', function () { - $(this).children(".modalResponse").empty().attr('class','modalResponse') + $(this).find(".modalResponse").first().empty().attr('class','modalResponse'); }) }) ); \ No newline at end of file diff --git a/static/js/stock.js b/static/js/stock.js index 6b2cb8f..ea609e2 100644 --- a/static/js/stock.js +++ b/static/js/stock.js @@ -3,43 +3,45 @@ var addStockModal = $('#addStockModal') var itemForm = $('#addItemForm'); var stockForm = $('#addStockForm'); $( document ).ready( - itemForm.submit(function() { + addItemModal.submit(function() { + addItemModal.find(".modalResponse").first().empty().attr('class','modalResponse'); $.ajax({ type: itemForm.attr('method'), url: itemForm.attr('action'), data: itemForm.serialize(), success: function(data) { - addItemModal.modal('hide') - location.reload() + addItemModal.modal('hide'); + location.reload(); }, error: function(data) { - itemForm.children(".modalResponse").empty().append('×') - itemForm.children(".modalResponse").append(data.responseText) - itemForm.children(".modalResponse").addClass("alert alert-danger fade in"); + addItemModal.find(".modalResponse").first().empty().append('×'); + addItemModal.find(".modalResponse").first().append(data.responseText); + addItemModal.find(".modalResponse").first().addClass("alert alert-danger fade in"); } }); return false; }), stockForm.submit(function() { + addStockModal.find(".modalResponse").first().empty().attr('class','modalResponse'); $.ajax({ type: stockForm.attr('method'), url: stockForm.attr('action'), data: stockForm.serialize(), success: function(data) { - addStockModal.modal('hide') - location.reload() + addStockModal.modal('hide'); + location.reload(); }, error: function(data) { - stockForm.children(".modalResponse").empty().append('×') - stockForm.children(".modalResponse").append(data.responseText) - stockForm.children(".modalResponse").addClass("alert alert-danger fade in"); + addStockModal.find(".modalResponse").first().empty().append('×'); + addStockModal.find(".modalResponse").first().append(data.responseText); + addStockModal.find(".modalResponse").first().addClass("alert alert-danger fade in"); } }); return false; }), - $("modal").each( function() { + $(".modal").each( function() { $(this).on('hidden.bs.modal', function () { - $(this).children(".modalResponse").empty().attr('class','modalResponse') + $(this).find(".modalResponse").first().empty().attr('class','modalResponse'); }) }) ); \ No newline at end of file diff --git a/templates/public/orders.html b/templates/public/orders.html index 87362e6..44b011b 100644 --- a/templates/public/orders.html +++ b/templates/public/orders.html @@ -73,7 +73,7 @@

Orders

-
+