posted 18 years ago
Hi,
Could anyone please recommend a design approach for keeping more than 1 event handler, for the same event ?
In particular, could you keep such handlers un-aware of each other?
Simplified example:
Say I started off with 2 independent requirements for a text input's "onkeyup()" :
- Some text-inputs should only allow lower-case letters
- Other(!) text-inputs should sound a 'beep' while tying.
Then this works:
However, later the requirements evolve, and *some* text-inputs need both effects (beep & lowercase). While other fields need a single effect (eg. just beep).
Of course, I could write a new 'onkeyup()' function that performs both actions (beep and lowercase).
But I really wish I could make it cleaner:
In real life my 'Handlers' are more complex, there are more Handlers and more combinations.
What is the best way to allow such combinations, while keeping my handlers un-aware of each other?
Thanks very much!
[ March 15, 2007: Message edited by: Sol Mam-Orn ]
[ March 15, 2007: Message edited by: Sol Mam-Orn ]