On 10/27/2011 10:45 AM, Carl Wiedemann wrote:
A better method of doing this is to specify JS event handlers via a separate file in drupal_add_js() using Drupal.behaviors. I don't know of go-to documentation for this off of the top of my head, but do some searching and look at examples in other core modules.
Perhaps something like:

// Using the closure to map jQuery to $. 
(function ($) {
  // Store our function as a property of Drupal.behaviors.
  Drupal.behaviors.myModuleSecureLink = {
    attach: function (context, settings) {
      $('#formid #input-name').bind('focus', function() {
        alert('User clicked on "foo."');
      });
    }
  }
}(jQuery));

-- 
Michael Favia                   michael@favish.com
tel. 512.669.5650            http://www.favish.com