Understanding Javascript scope with "var that = this"
<p>Say I have the following property method in an object:</p>

<pre><code>  onReady: function FlashUpload_onReady()
  {
     Alfresco.util.Ajax.jsonGet({
       url: Alfresco.constants.PROXY_URI + "org/app/classification",
       successCallback: {
         fn: function (o) {
           var classButtonMenu = [],
               menuLabel, that = this;

           var selectButtonClick = function (p_sType, p_aArgs, p_oItem) {
               var sText = p_oItem.cfg.getProperty("text");
               that.classificationSelectButton.set("label", sText);
           };

           for (var i in o.json.items) {
             classButtonMenu.push({
               text: o.json.items[i].classification,
               value: o.json.items[i].filename,
               onClick: {fn: selectButtonClick}
             });
           }

           this.classificationSelectButton = new YAHOO.widget.Button({
             id: this.id + "-appClassification",
             type: "menu",
             label: classButtonMenu[0].text,
             name: "appClassification",
             menu: classButtonMenu,
             container: this.id + "-appClassificationSection-div"
           });
         },
         scope: this
       },
       failureMessage: "Failed to retrieve classifications!"
     });
</code></pre>

<p>It took me some guess work to figure out that in the <code>selectButtonClick</code> function that I needed to reference <code>that</code> instead of <code>this</code> in order to gain access to <code>this.classificationSelectButton</code> (otherwise it comes up <code>undefined</code>), but I'm uncertain as to why I can't use <code>this</code>.  My best guess is that any properties in the overall object that gets referenced within <code>new YAHOO.widget.Button</code> somehow looses scope once the constructor function is called.</p>

<p>Could someone please explain why it is that I have to reference <code>classificationSelectButton</code> with <code>var that = this</code> instead of just calling `this.classificationSelectButton'?</p>
