Creating CheckList Rows on Submit
Next, you will add a method to CheckList that will use the Row constructor to create Row instances. It will append each Row instance’s $element to the live DOM on the page.
In
checklist.js, add a method to
CheckList.prototype
called
addRow. It should accept an argument called
coffeeOrder
, which will be an object that contains all of the
data for a single coffee order.
In this new method, create a new Row
instance by calling the Row constructor and
passing it the coffeeOrder
object. Assign the new
instance to the variable
rowElement. Then,
append
the rowElement’s
$element property (which contains the DOM
subtree) to the
CheckList instance’s
$element property (which is a reference to the container for ...
Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.