Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions burger_app/public/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// comments?!

// probably want a more descriptive name than $form since there
// are a bunch of forms
var $form = $("#ajax-form");

$form.submit(function(event) {
Expand All @@ -8,14 +12,19 @@ $form.submit(function(event) {
name: myName,
price: myPrice
}).done(function(data){
// convention to call this $div since it is a jquery element
var div =$('div').first().clone();
div.attr('id', data._id);
// good to remove logs when they are no longer needed
console.log(div.children())
// I might have grabbed these value by class indexing into children is
// a brittle method to do this
div.children()[0].value = data.name;
div.children()[1].value = data.price.toString();
div.children()[3].value = data._id;
div.children()[4].value = data._id;
$('#ingredientList').append(div);
// make sure you rebind any event handlers that your new div needs
});
});

Expand Down Expand Up @@ -63,6 +72,7 @@ $("#addOrder").submit(function(event){
event.preventDefault();
var checked = $('.checkbox');
var ingrs = '';
// this would be a great spot for checked.forEach or checked.map
for (i=0;i<checked.length;i++){
if (checked[i].checked){
ingrs += checked[i].name + ' ';
Expand Down
2 changes: 2 additions & 0 deletions burger_app/routes/orders.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var Ingredients = require('../models/ingredientModel.js');
var Orders = require('../models/orderModel.js');
var routes = {};

// there are some real strange errors from storing one total on your server which gets accessed by every client. I would sugest sending up the amount the total should change to the client and letting each client deal with keeping track of the total
var total = 0;

routes.orders = function (req,res){
Expand Down