plugins - javascript private variables access problem -


For this JavaScript master:

I'm experimenting with a new javascript framework. Its structure is inspired by someone other than powerful jQuery.

There is a global variable named $ j , and look at it in action:

  / * file: jfoo Js * / $ j = new (function () {var module = []; this.loadModule = function (mod) {modules [modules.length] = mod;} this.hasModule = function (mod) {for (ind In module) if (module [ind] == modern) returned; return false;}}) ();  

You see that the module is a private variable. no problem; That's what I wanted to do.

Now, I want to write a plugin that adds a $ j.loadBatch method to my system. Then ..

  / * file: loadBatch.jfoo.js * /! $ J || (Function () {$ j.loadBatch = function} {for (in the industry batch) module [modules.length ++] = batch [ind]}}) ();  

But, because this method is not part of the shutdown in file jfoo.js , this is not possible.

I also tried this version:

  / * file: jfoo.js * / $ j = new (function () {var module = []; this. LoadModule = function (mod) {module [module length] = mod;} this.hasModule = function (mod) {for ind in modules} if (modules [ind] == mod) will return; return returned;} This.extend = function {extensions} {for (ext extension) this [ext] = extension [ext];}}) ();  

and

  / * file: loadBatch.jfoo.js * /! $ J || (Function () {$ j.extend ({loadbatch: function} {for (in the industry batch) module [modules.length ++] = batch [india];}});});  

But I did not get any better results.

So, the question:

  • Is there any way that I use the loadbatch method in a different file and still the private method modules Can reach? (I hope there will be no answer, but who knows?)
  • Is there any other way by which I can achieve the desired effect without making the modules public? (I know how to move forward if I make it public)
  • Is the use of jQuery's private members?

Thanks,

jrh


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -