Reputation: 3457
I have a yepnope.js file which loads several other JavaScript files.
In yepnope.js I have a variable called applicationVersion
, which I append to the end of load url
like this: load: 'fileToLoad.js?v=' + applicationVersion
to enable cache busting!
Now I need to be able to access this applicationVersion
from fileToLoad.js
to enable cache busting for other functions within fileToLoad.js
. Can I just access the variable from fileToLoad.js
like the following?
//in fileToLoad.js
var ajaxUrl = '/json/messages?v=' + applicationVersion;
Or do I need other mechanisms to somehow pass the variable down from yepnope.js
to fileToLoad.js
?
I am not in an environment where I can test this out.
Upvotes: 1
Views: 54
Reputation: 50291
You can pass the applicationVersion
with using a namespacing a variable.Hope this following snippet will help
Assuming this is your yepnope.js
var myYepnope = myYepnope || {} //Defining namespace;
myYepnope.applicationVersion:"someVesrion";
myYepnope.loader =function(){
// code related to yepnope file loader
}
myYepnome.loader() // to execute the function
Now applicationVersion
will be accessible from fileToLoad.js by calling myYepnope.applicationVersion
A change in value of myYepnope.applicationVersion
will be reflected everywhere
Upvotes: 2