Click here to Skip to main content
15,896,557 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: Javascript/jquery problem Pin
Dennis E White22-May-13 10:31
professionalDennis E White22-May-13 10:31 
GeneralRe: Javascript/jquery problem Pin
#realJSOP23-May-13 0:54
professional#realJSOP23-May-13 0:54 
GeneralRe: Javascript/jquery problem Pin
Dennis E White23-May-13 4:09
professionalDennis E White23-May-13 4:09 
GeneralRe: Javascript/jquery problem Pin
#realJSOP24-May-13 2:54
professional#realJSOP24-May-13 2:54 
GeneralRe: Javascript/jquery problem Pin
Dennis E White24-May-13 6:08
professionalDennis E White24-May-13 6:08 
GeneralRe: Javascript/jquery problem Pin
#realJSOP25-May-13 11:18
professional#realJSOP25-May-13 11:18 
GeneralRe: Javascript/jquery problem Pin
Dennis E White25-May-13 11:27
professionalDennis E White25-May-13 11:27 
GeneralRe: Javascript/jquery problem Pin
#realJSOP26-May-13 2:49
professional#realJSOP26-May-13 2:49 
Dennis E White wrote:
have you tried debugging with Chrome??

 

Yes. That's what I'm using now.
Dennis E White wrote:
hahaha... it's the whole this concept mixed with callback functions isn't it?

Well, sort of. I have something like the following:
JavaScript
var TOH = function(in_path, in_parentDiv, in_mouseOver)
{
    var _array   = new Array(),
        _xmlFile = "",
        _data1   = "",

        init = function(path, parentDiv, mouseOver)
        {
            // this variable assigment seems to "stick" as expected
            _xmlFile = path + "datafile.xml";

            loadData();
        },

        loadData = function()
        {
            // sometimes the file gets loaded, sometimes it errors out. 
            // I'm having a real problem determining why.
            $.ajax
            ({
                 type: "GET"
                 ,url: _xmlFile
                 ,dataType: "xml"
                 ,success: function(xml)
                 {
                     parseConfig      ($(xml).find('Config'));
                     parseImages      ($(xml).find('Images'));
                 }
                 ,error: function(jqXHR, status, error) 
                 {
                     alert(error);
                 }
             });
       },

       parseConfig = function(nodelist)
       {
           // when this line executes, _data1 contains the expected string
           _data1 = $(nodelist).find("Item1").text();
           // when this function exits, _data1 is empty again
       },

       parseImages = function(nodeList)
       {
          if (nodeList != null)
          {
              $(nodeList).find('Image').each(function()
              {
                  var count = _array.length;
                  // TreeImage is an object defined elsewhere in the code
                  _array[count] = new TreeImage(this, count, _data1, 0);
              });
           }
           // when the code gets here, the _array has the expected number of 
           // elements, bit when the function returns, the _array is empty.
       };

    init(in_path, in_parentDiv, in_mouseOver);
};


In any case, I THOUGHT that the vars defined in TOH were going to be set by the functions that are also in TOH. That doesn't appear to be the case at all, and instead, the variables appear to be defined within the confines of each function, and once the function exits, the variables in TOH are unchanged from their original values. What's really puzzling is that when I call init, it properly sets the vars defined in TOH, so I'm sitting here pissed off because I don't understand why.

Another mystery is that despite having well over a dozen vars defined in TOH, only a few show up in the associated "Closures" panel in the debugger. Each var is initialized to a value when it's declared, so I don't understand why they don't show up.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997



modified 26-May-13 9:27am.

GeneralRe: Javascript/jquery problem Pin
User 171649225-May-13 11:37
professionalUser 171649225-May-13 11:37 
GeneralRe: Javascript/jquery problem Pin
#realJSOP26-May-13 3:01
professional#realJSOP26-May-13 3:01 
GeneralRe: Javascript/jquery problem Pin
User 171649226-May-13 4:47
professionalUser 171649226-May-13 4:47 
QuestionHow to Add Days in Javascript Date Object Pin
Robymon22-May-13 2:26
Robymon22-May-13 2:26 
AnswerRe: How to Add Days in Javascript Date Object Pin
Richard Deeming22-May-13 3:23
mveRichard Deeming22-May-13 3:23 
AnswerRe: How to Add Days in Javascript Date Object Pin
Dennis E White22-May-13 4:39
professionalDennis E White22-May-13 4:39 
AnswerRe: How to Add Days in Javascript Date Object Pin
Niral Soni23-May-13 1:23
Niral Soni23-May-13 1:23 
Questionfunction for split a complex string Pin
mhd.sbt21-May-13 7:06
mhd.sbt21-May-13 7:06 
AnswerRe: function for split a complex string Pin
ZurdoDev21-May-13 10:30
professionalZurdoDev21-May-13 10:30 
AnswerRe: function for split a complex string Pin
Dennis E White22-May-13 4:53
professionalDennis E White22-May-13 4:53 
AnswerRe: function for split a complex string Pin
Niral Soni23-May-13 2:36
Niral Soni23-May-13 2:36 
QuestionReading XML - success being ignored Pin
#realJSOP21-May-13 1:01
professional#realJSOP21-May-13 1:01 
AnswerRe: Reading XML - success being ignored Pin
Dennis E White21-May-13 4:49
professionalDennis E White21-May-13 4:49 
GeneralRe: Reading XML - success being ignored Pin
#realJSOP21-May-13 5:00
professional#realJSOP21-May-13 5:00 
GeneralRe: Reading XML - success being ignored Pin
Dennis E White21-May-13 5:13
professionalDennis E White21-May-13 5:13 
GeneralRe: Reading XML - success being ignored Pin
#realJSOP21-May-13 5:40
professional#realJSOP21-May-13 5:40 
GeneralRe: Reading XML - success being ignored Pin
Dennis E White21-May-13 5:44
professionalDennis E White21-May-13 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.