Basically, if I have 3 javascript files and I want all of them to belong to the same "package", how do I do that? Because if I code each of them the same way, the initial declaration in one package seems to blow away the declaration of another. And the same with the "pub"lic vars. I will have to see if there is some forum discussing this. I'm sure there is.
The code is actually kind of cool for javascript. Now if there was only a javascript IDE with Intellisense. That would be awesome!
The basic code that I am using Mark Ziesemer came up with. It basically lets me "wrap up" all of my "loose" javascript variables into a namespace and then access just the ones I make public from the XUL Chrome. It's pretty cool. Here is Mark's example:
if(!com) var com={};
if(!com.ziesemer) com.ziesemer={};
com.ziesemer.myPackage = function(){
var pub = {};
pub.name = "visitor";
pub.greeting = "hello " + pub.name;
pub.alertHello = function(){
alert(pub.greeting);
};
return pub;
}();
com.ziesemer.myPackage.alertHello();
of couse com.ziesemer belongs to Mark, so your should be "com.yourname" or whatever..
.
No comments:
Post a Comment