Binding the user controls
Now that we have converted our application to use AMD modules, let's gradually increase the complexity of the application. Currently, we search the DOM for individual elements and attach event handlers to them. This isn't necessarily a bad thing; however, it does leave our code vulnerable to a number of possible issues. The DOM may not have finished rendering the objects we are attempting to attach to, or the object could have been removed by another segment of code. Another pitfall of this approach is that if we wanted to add another drawing shape type to our application, we would have to add another element to the HTML and then more code to add the event handler. This is inefficient and could open up the possibility ...
Get TypeScript Essentials 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.