new Element('script', {src: url, events: { load: fn }
}).inject(document.head)

On Wed, Nov 4, 2009 at 4:41 PM, jiggliemon <ch...@agroism.com> wrote:

>
> At it's root, it's a problem with Asset.javascript().  What's
> happening is Asset grabs the JS file, but the javascript moves on
> before it's completed loading.  Even when I add functions to onload
> they're being called too late.
>
> Is there another way to get a javascript file without Asset?  I need
> somthing that i can attach an onComplete function to, and not have it
> move on w/o completing.
>
> Request.JSON?
> Request?
>
> -Chase
>
> On Nov 3, 11:27 pm, csuwldcat <daniel...@gmail.com> wrote:
> > Are you essentially trying to preload a script before firing a
> > function, initializer, or dependent code chunk?  If so check this
> > out:  http://blog.citycrawler.com/?p=47
> >
> > - Daniel
> > le
> > On Nov 3, 5:17 pm, jiggliemon <ch...@agroism.com> wrote:
> >
> > > 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