Skip to content

Commit

Permalink
Fixed some JS issues
Browse files Browse the repository at this point in the history
Didn't search for classes correctly
  • Loading branch information
Kaezon committed Apr 15, 2016
1 parent 86065f2 commit d6e896d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
15 changes: 8 additions & 7 deletions static/js/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="#" class="close" data-dismiss="alert">&times;</a>')
$("#orderModalResponse").append(data.responseText)
$("#orderModalResponse").addClass("alert alert-danger fade in");
orderModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
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');
})
})
);
28 changes: 15 additions & 13 deletions static/js/stock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<a href="#" class="close" data-dismiss="alert">&times;</a>')
itemForm.children(".modalResponse").append(data.responseText)
itemForm.children(".modalResponse").addClass("alert alert-danger fade in");
addItemModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
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('<a href="#" class="close" data-dismiss="alert">&times;</a>')
stockForm.children(".modalResponse").append(data.responseText)
stockForm.children(".modalResponse").addClass("alert alert-danger fade in");
addStockModal.find(".modalResponse").first().empty().append('<a href="#" class="close" data-dismiss="alert">&times;</a>');
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');
})
})
);
2 changes: 1 addition & 1 deletion templates/public/orders.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1 class="page-header text-center">Orders</h1>
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Add New Order</h4>
</div>
<div id="orderModalResponse"></div>
<div class="modalResponse"></div>
<div class="modal-body">
<form id="orderForm" method="post" action="">
{% csrf_token %}
Expand Down

0 comments on commit d6e896d

Please sign in to comment.