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.
You can pass the
applicationVersionwith using a namespacing a variable.Hope this following snippet will helpAssuming this is your yepnope.js
Now
applicationVersionwill be accessible from fileToLoad.js by callingmyYepnope.applicationVersionA change in value of
myYepnope.applicationVersionwill be reflected everywhere