Because i love the Joomla file structure so much and the factory
pattern, I decided to implement something similar with my JS library.

My page loads by default, Core.js, More.js, Agro.js, and template.js
by default.
I'm getting all kinds of errors in the Firebug. Mainly i think it's an
issue of setting what would be a static property in in php for
"comments".  How would i assign a global property so that the rest of
the methods can reach it?



In my template.js file i have:
-----------------------------------------
window.addEvent('domready', function() {

        var agro = new Agro();

        var comments = agro.getComments();
        alert(comments.toString);
});


in my Agro.js file it has:
-----------------------------------------
var Agro = new Class({
        comments:null,
        Implements: [Events, Options],

        options: {
                comments: null,
        },
        initialize: function(){
                console.log('Agro class loaded');
        },
        getComments: function(){
                if(!$chk(window.Asset)) getMore();
                if(!$chk(window.AgroComments)){
                        new 
Asset.javascript('/media/system/js/agro/comments.js',{
                                onload: function(){
                                        this.comments = new AgroComments();
                                        console.log('comments has finally 
loaded.');
                                }
                        });
                }
                return this.comments;
        }
});
Agro.implement(new Events, new Options);


in my Comments.js file it has:
-----------------------------------------
var AgroComments = new Class({
        Implements: [Events, Options],
        options: {},
        initialize: function(){
                console.log('AgroComments has been initialized.');
        },
        raise: function(error){
                alert(error);
        },
        toString:'totally'
});

AgroComments.implement(new Events, new Options);

---------------------
---------------------
---------------------

Reply via email to