4.2.5Adding Behavior
Now we can add some actions by defining callbacks attached to anchors, see Figure 37. A callback is a piece of code that will be executed when a link is clicked. We will explain this in detail later in the book. Modify the method WAComponent>>renderContentOn:
as follows and commit your changes.
WebCounter>>renderContentOn: html
html heading: count.
html anchor
callback: [ self increase ];
with: '++'.
html space.
html anchor
callback: [ self decrease ];
with: '--'
Now when you click on the links you will see the counter increment or decrement.