> 'scriptadded' does get reset to false just after the loop counter 'i'
> is incremented

Doh!  Sorry I missed that.

>, and in fact through Firebug I can see the <script/>
> tags appearing in the HTML - so I know this aspect of the code is
> working.

I think your issue is with these lines in the scripts:

    var Stu = window.Stu || {};

You're declaring that via `var`, but looking for it as a property of
`window`. There is some weirdness about global `var` statements and
window properties which I'd try to avoid by being explicit:

    if (!window.Stu) {
        window.Stu = {};

...or if you prefer the functional style:

    window.Stu = window.Stu || {};

> > OT: Why the `eval`?
> I know its use is to be avoided but I couldn't see a way around it.

You can check the individual parts of the path. If you change
`scripts` to

    var scripts = [
        { src: 'js/s1.js' , obj: ['Stu', 's1', 'func'] },
        { src: 'js/s2.js' , obj: ['Stu', 's2', 'func'] },
        { src: 'js/s3.js' , obj: ['Stu', 's3', 'func'] }

...you could use

    function checkObjExists(context, path) {
        var index;

        for (index = 0; index < path.length; ++index) {
            context = context[path[index]];
            if (!context) {
                // This part wasn't found
                return false;

        // Found
        return true;

...like so:

    if ((window.Stu) && (checkObjExists(window, scripts[i].obj))) {

If you prefer to keep your scripts string the way it is, just use
`scripts[i].obj.split('.')` to create the array on the fly.

T.J. Crowder
Independent Software Consultant
tj / crowder software / com
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to