Time for action – Setting up the controller
We will set up our controller as computerList.controllers.ComputerListController
.
It will have to handle actions on the different view's elements (particularly when the user clicks the add button).
Note that we will create another view after that for each row of the table (it will be a ComputerView
).
Therefore, here is our ComputerListController.hx
file:
package computerList.controllers; import js.Dom; import js.Lib; import computerList.models.Computer; class ComputerListController { var listBody:js.HtmlDom; var nameField:js.Text; var osField:js.Select; var detailsField:js.Text; var addButton:js.Button; public function new() { listBody = untyped Lib.document.getElementById("listTable").tBodies[0]; nameField = cast Lib.document.getElementById("name"); osField = cast Lib.document.getElementById("OS"); detailsField = cast Lib.document.getElementById("details"); addButton = cast Lib.document.getElementById...