Andres at Web 2.0 Technologies has a very informative post about how to use object oriented techniques to implement a robust event broadcasting and listening in javascript. Follow his advise an dmake your code more reusable.
What do you want to invoke when the checkbox object changes state? If you’re programming it
in a non-reusable way, you can hard-code the action directly into the onclick event:
if (state==checked) do X; if (state==grayed_out) do y; etc. If you’re programming it
as a reusable component, you need a more flexible solution.