access javascript variables outside the scope of a jquery function
<p>I have a <code>jquery</code> function to display a menu on right click event.
I wish to access an object from the parent function inside the <code>callback</code> function.</p>

<p>Am using <a href="http://medialize.github.com/jQuery-contextMenu/" rel="nofollow">following</a> JQuery plugin to get the context menu.</p>

<p>Here is the code:</p>

<pre><code>function OnContextMenu() {

     //alert(key + ' ' +this.Node.Content);
     var localNode = this.Node;
     alert(localNode.Content); //CORRECT NODE VALUE GETS ALERTED

        $.contextMenu({
            selector: '.Container', 
            callback: function(key, options) {
                var m = "clicked: " + key;
                 alert(localNode.Content); //ALWAYS PRINTS THE VALUE OF THE VERY FIRST NODE THAT WAS CLICKED. 
                // window.console &amp;&amp; console.log(m) || alert(m); 
            },
            items: {
                "edit": {name: "Edit", icon: "edit"},
                "cut": {name: "Cut", icon: "cut"},
                "copy": {name: "Copy", icon: "copy"},
                "paste": {name: "Paste", icon: "paste"},
                "delete": {name: "Delete", icon: "delete"},
                "sep1": "---------",
                "quit": {name: "Quit", icon: "quit"}
            }
        });
    }
</code></pre>

<p>As you can see I am storing the value in a variable:</p>

<pre><code>var localNode = this.Node;
</code></pre>

<p>and using this variable inside the <code>callback</code> function. 
Peculiar thing about this is, the <code>alert(localNode.Content);</code> inside the callback gives correct value when the menu is clicked the very first time. After that even though the <code>alert</code> of the outer function gives different values correctly, the inner callback function keeps displaying the same old value as that of the first time.</p>
