Confused why this javascript is causing me issues. Defined a class and prototype methods
<p>I have the following which is a simplified version of what I have:</p>

<pre><code>function MyClass(a,b) {
  this.a = a;
  this.b = b;
}

MyClass.prototype.f1 = function(a) {
    this.a = a;
};

MyClass.prototype.f2 = function(a) {
    this.f1(a);
};

var mc1 = new MyClass(1,2);
</code></pre>

<p>Now I am getting an error saying:</p>

<pre><code>this.f1 is undefined
</code></pre>

<p>If I move f1 out to its own function, there error is gone.</p>

<p>What could be causing this problem?
I know if you run the simplified version above it should work, but what could be causing the issue in my codebase?  (I can't post it here, but any hints on what to look for?)</p>

<p><b>Update</b></p>

<p>Ok after tracing it in firebug, it seems the keyword 'this' has been rebound somehow and it is no longer bound to the class MyClass, hovering over it is shows 'function'.</p>

<p>What happened is that I set this function MyClass.f2 as a callback to Telerik editor, and it has somehow changed the scope of 'this'.</p>

<p><strong>What are my options to fix this?</strong></p>
