title: javascript prototype class, this in jquery click
body: <p>I made a javascript prototype class.</p>
  
  <p>Inside a method I create an jquery click.
  But inside this click I want to execute my build function.</p>
  
  <p>When I try to execute a prototype function inside a jquery click it fails because jquery uses this for something else.</p>
  
  <p>I tried some different things, but I couldnt get it working.</p>
  
  <pre><code>Game.prototype.clicks = function(){
      $('.flip').click(function(){
  
          if(cardsPlayed.length &lt; 2) //minder dan 2 kaarten gespeeld
          {
              $(this).find('.card').addClass('flipped');
              cardsPlayed.push($(this).find('.card').attr('arrayKey'));
  
              console.log(cardsPlayed[cardsPlayed.length - 1]);
  
              console.log(playingCards[cardsPlayed[cardsPlayed.length - 1]][0]);
  
              if(cardsPlayed.length == 2)// two cards played
              {
                  if(playingCards[cardsPlayed[0]][0] == playingCards[cardsPlayed[1]][0])
                  { // same cards played
                      console.log('zelfde kaarten');
                      playingCards[cardsPlayed[0]][0] = 0; //hide card one
                      playingCards[cardsPlayed[1]][0] = 0; //hide card two
                      //rebuild the playfield
                      this.build(); //error here
                  }
                  else
                  {
                      //differend cards
                  }
  
              }
          }
  
          return false;
      }).bind(this);
  }
  </code></pre>