Handling Control Events
Atlas provides its client controls with an event handling mechanism. The mechanism works a bit differently than you might expect, but it’s still intuitive.
The first and most important step is to call the initialize() method of the element whose events
you want to handle. This enables all the mechanisms that are internally used to capture events. Then setting up events is a two-step process.
Write an event handling function that is called when the event occurs.
Link the event handling function to the element using
<element>.<eventname>.add(<method name>). The syntax is reminiscent of the event handling mechanism that the DOM provides for JavaScript (although it is not always used that way) and roughly on the .NET Framework implementation of delegates.
Events for Buttons
Remember the example with the three modal pop-up windows from the beginning of this chapter? There, the JavaScript code to display the windows was added declaratively in the HTML button. This can also be done using the Atlas library, but in that case, you do not gain much from using Atlas in comparison to the “pure” JavaScript way, except for the certainty that the Atlas library is fully loaded before attaching any JavaScript code to an element. However, the whole idea of the Atlas framework is to bring server-side and client-side development closer to each other and to bring new OOP capabilities and browser independence to the client. Therefore, using Atlas for tasks that you can ...