How can I access variables outside of current scope in javascript?

Posted by sekmet64 on Stack Overflow See other posts from Stack Overflow or by sekmet64
Published on 2010-05-02T20:20:22Z Indexed on 2010/05/02 20:28 UTC
Read the original article Hit count: 251

Filed under:
|
|

I'm writing some application in javascript and cannot figure it out how to access the variables declared in my function, inside this jquery parse. Inside I can access global variables, but I don't really want to create global vars for these values.

Basically I want to extract file names from an xml document in the simulationFiles variable. I check if the node attribute is equal with the simName and extract the two strings inside the xml elements, that part I think it's working.

How can I extract those xml elements and append them to local variables?

function CsvReader(simName) {
    this.initFileName = "somepath";
    this.eventsFileName = "somepath";
    $(simulationFiles).find('simulation').each(function() {
       if ($(this).attr("name") == simName) {
           initFileName += $(this).find("init").text();
           eventsFileName += $(this).find("events").text();
       }
    });
}   

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery