Focusing a form field at page load with MochiKit
Code snippets you find online will typically do something like:
<html> <head> ... </head> <body onload="document.someform.somefield.focus()"> ... </body> </html>
That’s nice and all, but this can be problematic when you have other onload methods for your body tag.
MochiKit has some nice facilities for handling events like this, what it calls MochiKit.Signal. It allows you to connect however many functions to a particular event as you need.
Here’s how I did it:
Pretty simple. This is only scratching the surface of MochiKit’s Signal handling.