title: Javascript event handler with parameters
body: <p>I want to make an <code>eventHandler</code> that passes the event and some parameters. The problem is that the function doesn't get the element. Here is an example:</p>
  <pre><code>doClick = function(func){
      var elem = .. // the element where it is all about
      elem.onclick = function(e){
          func(e, elem);
      }
  }
  doClick(function(e, element){
      // do stuff with element and the event
  });
  </code></pre>
  <p>The <code>elem</code> must be defined outside of anonymous function. How can i get the passed element to use within the anonymous function? Is there a way to do this?</p>
  <p>And what about <code>addEventListener</code>? I don't seem to be able to pass the event through an <code>addEventListener</code> at all do I ?</p>
  <p><strong>Update</strong></p>
  <p>I seemed to fix the problem with 'this'</p>
  <pre><code>doClick = function(func){
      var that = this;
      this.element.onclick = function(e){
          func(e, that);
      }
  }
  </code></pre>
  <p>Where this contains <code>this.element</code> that i can access in the function.</p>
  <p><strong>The addEventListener</strong></p>
  <p>But i'm wondering about the <code>addEventListener</code>:</p>
  <pre><code>function doClick(elem, func){
      element.addEventListener('click', func(event, elem), false);
  }
  </code></pre>