Call class function and access class property in jQuery method
<p>I had problem in my other code and huge, but I had made one prototype here,</p>

<p>this code is suppose to alert
"hello John" instead of "hello undefined" </p>

<pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script src="jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" language="javascript"&gt;
        function callMethod(data, callback) {
            return callback(data);
        }

        function client(divid) {
            this.init = function () {
                $(this.divid).click((function (context) {
                    return function () {
                        callMethod("hello ", context.method);
                    }
                })(this));
            }
            this.divid = "#" + divid;
            this.myname = "John";
            this.method = function (d) {
                alert(d + this.myname);
            }
            this.init();
        }

        $('document').ready(function () {
            new client("mydiv");
        });
    &lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id="mydiv"&gt;This is my div&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>can some body point out me why I'm getting unexpected result here?</p>

<p>I'm getting unexpected result on</p>

<pre><code>this.method = function (d) {
    alert(d + this.myname);
}
</code></pre>

<p>this.myname suppose to return "John" here. </p>

<p><a href="http://stackoverflow.com/questions/1900116/how-to-access-class-instance-in-event-hanlder-javascript/1900143#1900143">How to access class instance in event hanlder (JavaScript)?</a>
I'm getting help from above link, but I'm not being able to solve</p>
