O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Creating a computer view

Now, let's create a simple view for Computer. It will be named computerList.views.ComputerView:

package computerList.views; import computerList.models.Computer; import js.Dom; import js.Lib; class ComputerView { var computer:Computer; public var mainNode:js.HtmlDom; //To let the parent view know when we delete our object public var on Delete:ComputerView -> Void; public function new(comp:Computer) { computer = comp; mainNode = Lib.document.createElement("tr"); var nameCell = Lib.document.createElement("td"); nameCell.appendChild(Lib.document.createTextNode(computer.name)); var osCell = Lib.document.createElement("td"); var detailsCell = Lib.document.createElement("td"); osCell.appendChild(Lib.document.createTextNode) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required