I am having a lot of issues with jquery. I am managing an older application that used prototype. My new pages don't use prototype, but I am encapsulating things in jquery.noConflict just in case. This however is resulting in me being unable to share functions through different js files.
Order files are loaded:
jquery.js
jquery.commonFuncs.js
jquery.database.js
Example contents of files
commonFuncs.js
var someGlobalVar = "abc";
jQuery.noConflict()(function($){
function doStuff(x){
return x;
}
});
database.js
jQuery.noConflict()(function($){
var a = 123;
doStuff(a);
});
Error: doStuff is not defined.
I can kind of understand why encapsulating the function removes it from the global namespace. How can I add it back?
I also have no darn idea why I have to use noConflict if I do not load prototype.js If I completely remove prototype.js and remove the noConflict encapsulation, I get $ is undefined, and I don't know where to start with that. jQuery is clearly loading first. No clue.