title: global custom events in jQuery
body: <p>I want to use custom jQuery events independent of DOM elements, but I'm not sure what the best way is to achieve this.</p>
  
  <p>Here's what I started out with:</p>
  
  <pre><code>// some system component registers an event handler
  $().bind("foo.bar", handler); // foo is my app's namespace, bar is event name
  // another part of the system fires off the event
  $().trigger("foo.bar", { context: "lorem ipsum" });
  </code></pre>
  
  <p>After looking at jQuery's source, in particular its handling of global AJAX events, I figured this should work:</p>
  
  <pre><code>$.fn.bind("foo.bar", handler);
  // ...
  $.event.trigger("foo.bar", { context: "lorem ipsum" });
  </code></pre>
  
  <p>However, it appears that my handler function is never even called.</p>
  
  <p>Am I perhaps going about this the wrong way?</p>