When I do event listeners because of one of the following cases
1) When the same event is needed for many elements, for example for each
row of a table. Adding a listener to the container, table in my example,
and wait for the event to bubble from the row to the table. It is
cleaner than dozens on onclick attributes
2) When the client side JavaScript adds new elements that need events
captured, Using 1) you can add as many rows client side and the event
listener are already in place for each one
3) When I want automatic events added without need to add on* attributes
everywhere. See for example Twitter Bootstrap, you some data-*
attributes and the base installed event handlers are reused in all the page
How I do this? I create a <script> element for the page with JcCmds
server side
Function("loadCatalog",
List("id"),
SHtml.ajaxCall(JsVar("id"), Repository.load)._2)
This adds a function that I can later call from my client side added
event listeners
SHtml.onEvent reference by Diego is nice and I probably will use it now
for when I do not need to do client side processing of the event (for
example as for confirmation), but will use it when the server will
receive the event signal directly
>
> /Jeppe
>