title: jQuery Callback inside Typescript Class
body: <p>Got a Problem with Typescript and jQuery. The elements get appended to body and show up but nothing happens when i click the button.</p>
  
  <p>I suppose its something with the this.fooClick() that gets passed to the button but doesnt get called or the wrong jquery elements gets saved to the class variables.</p>
  
  <p>Anyone help?</p>
  
  <p>test.ts</p>
  
  <pre><code>/// &lt;reference path="jquery.d.ts" /&gt;
  
  class foo {
  
      private button;
      private text;
  
      constructor() {
  
          this.button = $('&lt;button&gt;').html("click").click(this.fooClick());
          this.text = $('&lt;p&gt;').html("foo");
  
          $('body').append(this.button);
          $('body').append(this.text);
      }
  
      public fooClick() {
          $(this.text).html("bar");
      }
  
  }
  
  $(function() {
      var foobar = new foo();
  })
  </code></pre>
  
  <p>test.js</p>
  
  <pre><code>/// &lt;reference path="jquery.d.ts" /&gt;
  var foo = (function () {
      function foo() {
          this.button = $('&lt;button&gt;').html("click").click(this.fooClick());
          this.text = $('&lt;p&gt;').html("foo");
          $('body').append(this.button);
          $('body').append(this.text);
      }
      foo.prototype.fooClick = function () {
          $(this.text).html("bar");
      };
      return foo;
  })();
  $(function () {
      var bar = new foo();
  });
  </code></pre>