Would it be possible, and if so how, to have mootools automatically
call an __autoload function, if a class is not yet defined (javascript
file not yet loaded) when an attempt is made to instantiate a class?
What I'm looking for is the same functionality as __autoload() in PHP.
I've briefly looked at Depender (it will require deeper study), but
I'm not sure if I can make it do what I want.
The idea being that _autoload() would be passed the name of the class
that is to be instantiated, then it's up to me to write the code to
load the Javascript file for my library classes. By following a simple
naming convention, I could write the __autoload() code once and it
would work for all of my applications that use my library code
directory structure.
A basic __autoload() function would look something like this
function __autoload(className) {
var fileName = "myLibrary/" + className + ".js";
Asset.javascript(fileName);
}
This would need to be synchronous though because the javascript has to
load, then control has to revert back to the mootools Class code to
instantiate the class now that the javascript code has been loaded.
In this way, I don't have to worry about dependencies at all. Whatever
is needed automatically gets loaded as it's needed, if it hasn't
already been loaded.
--
To unsubscribe, reply using "remove me" as the subject.