title: jQuery draggable(), on drag perform a dynamic function
body: <p>I have a jQuery draggable() function and on drag is executing several other functions based on an if. Something like this:</p>
  
  <pre><code>$("div.element").draggable({
      drag: function() {
              if  (a=1){
                  function1();
                  }
              if  (a=2){
                  function2();
                  }   
              if  (a=3){
                  function3();
                  }   
      }
  });
  </code></pre>
  
  <p>There are many variables involved and I am looking to optimize this from the performance perspective point of view. Is it possible to make the draggable "know" what function to perform on drag without doing the <code>if</code> checking each time. Something like on drag do just function2() and function3().</p>
  
  <p>Thank you</p>