i dont get why I dont have check boxes
here is my checkList file data attribute is the same in my index.html)
(function(window) {
// body...
'use strict';
var App=window.App || {};
// importing APP and jQuery namespace line above and below
var $=window.jQuery;
function CheckList(selector){
if(!selector){
throw new Error('no selector provided');
}
this.$element=$(selector);
if(this.$element.length===0){
throw new Error('not find element with selector '+ selector);
}
}
// the parameter, coffeorder is data passed that contains a
//single coffe order like strength size etc...
CheckList.prototype.addRow= function(coffeeOrder) {
// pg 234
var rowElement=new Row(coffeeOrder);
//add the new row instance $row property to the checklist instance
//this.$element with append() method
this.$element.append(rowElement.$row);
};
// want mark up to appear after form submits, create another constructor!
//accepts coffeOrder which is same data form createorder from Truck.js file
function Row(coffeeOrder){
// use jquery to build DOM elements, more on pgs 229-231
var $div=$('<div><div>',{
'data-coffee-order':'checkbox',
'class':'checkbox'
});
var $label=$('<label><label>');
var $checkbox=$('<input><input>',{
type:'checkbox',
value:coffeeOrder.emailAddress
});
var description=coffeeOrder.size + ' ';
if(coffeeOrder.flavor){
description+=coffeeOrder.flavor+ ' ';
}
description+=coffeeOrder.coffee+ ' , ';
description+='(' + coffeeOrder.emailAddress + ')';
description+= '[' + coffeeOrder.strength +' x ]';
// below append() adds jquery collection or DOM elements
// as child elements
//start with inner tag, $checkbox and finish with outer tag, $div
$label.append($checkbox);
$label.append(description);
$div.append($label);
this.$row=$div;
}
// exporting checklist to app namespace below
App.CheckList=CheckList;
console.log('checklist running');
window.App=App;
})(window);