title: Common callback for all instances of a class in Javascript
body: <p>I've got a custom Javascript class that generates a JQuery mousedown callback. The mousedown callback is on $(document) and should really only be set for the first new instance, and not for any subsequent ones. I've got something like the following:</p>
  
  <pre><code>function myclass(arg){
     this.arg = arg;
     $(document).mousedown(function(down_event){
         // start action
     }).mouseup(function(){
        // stop action
        })
  }
  </code></pre>
  
  <p>I'd like those callbacks to only register once in the event that multiple <code>myclass</code> instances are crated, and not at all if none are created.</p>