Abstract: In this second part shows how to declaratively handle events raised by client side controls
In the first part of this tutorial on xml-script we introduced type descriptors and learned how to read them. In this second part we'll see how to declaratively handle events raised by client side controls.
Handling events
When talking about type descriptors in the first part of the tutorial, we stated that exposing a descriptor allows instantiating client side components using xml-script. Just by looking at the type descriptor of a class, we could get an idea of how the xml-script needed to create an instance, should look. For example, the Sys.Preview.UI.Button and the Sys.Preview.UI.Label classes contained in the PreviewScript.js file expose the following descriptors:
All the information we need to write the code in the following example is contained in the above descriptors. The code, based on the standard structure of an xml-script block of code, creates an instance of both the Button and the Label classes and wires the click event of the button with a JavaScript function that displays a message on the label.