So, after some hard trouble i came up with this "proof of concept":
http://jsfiddle.net/CsJ6C/13/

a few notes:
1. i kept your __autoload syntax, but you will need to implement it.
2. In order for this to work you will need to pass strings for Implements as
Extends, not the Objects (which obviously are not yet loaded).
3. i really haven't tried this out other than a simple use of Options, so i
don't know if i'm even doing this the right way (the real issue is passing
the arguments without using the new operator...)
-----------
אריה גלזר
052-5348-561
5561


On Wed, Apr 7, 2010 at 03:00, batman42ca <[email protected]> wrote:

> 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.
>

Reply via email to