Hi JoJo,

I suspect there's some small (but important) piece of information or
understanding that you don't have, being a beginner, but we're
shooting a bit in the dark trying to identify it.

Can you create an example of the problem using one very simple HTML
file and (say) two script files?  (Three if you need it to make the
problem occur.)  Paste them in Pastie[1] and drop us a link here, and
we'll try to figure it out.

FWIW, I've never had a problem with files getting loaded and executed
out of order.  I find it very, very hard to believe that that's
actually happening (Alex, if you have a reference for your earlier
comment, please do share it), the number of sites that would break is
legion.

If that really _is_ happening, another way to solve it is to combine
all of your JavaScript files into one file as part of a build
process.  There are good reasons for doing that anyway; more here.[2]

[1] http://pastie.org
[2] http://proto-scripty.wikidot.com/prototype:tip-minimizing-download-times

HTH,
--
T.J. Crowder
tj / crowder software / com
www.crowdersoftware.com

On Sep 4, 7:17 am, JoJo <tokyot...@gmail.com> wrote:
> My classes are just class definitions.
>
> MYAPP.Class1= Class.create({...});
> MYAPP.Class2= Class.create({...});
>
> I don't create the objects until I get to main.js, which creates them
> after the window has loaded.  Why is IE7 not giving an error when I
> access MYAPP in Class1.js and Class2.js, but is giving an error when I
> access it in main.js? This native and function object talk just went
> straight over my head.  I am only a beginner to JS.
>
> On Sep 3, 10:51 pm, RobG <robg...@gmail.com> wrote:
>
>
>
> > On Sep 4, 3:43 pm, RobG <robg...@gmail.com> wrote:
>
> > > On Sep 4, 4:40 am, JoJo <tokyot...@gmail.com> wrote:
>
> > > > ^ great article!
>
> > > > Now I have another question.  Here is my new workflow in an attempt to
> > > > execute files in the correct order across all browsers.  It works in
> > > > IE8, but not in IE7.  In IE7 I get an error saying "object expected"
> > > > on line 2 of main.js.  This is not very descriptive; what does it
> > > > mean?
>
> > > > (1) include my global wrapper MYAPP.js:
>
> > > >     MYAPP = {class1: null, class2: null}
>
> > > MYAPP is an instance of the built-in Object object (i.e. a native
> > > object). Because it has not been declared, it doesn't exist until the
> > > code is executed.
>
> > That is, until that line of code is executed.
>
> > > > (2) include Class1.js (no instantiation)
> > > > (3) include Class2.js (no instantiation)
> > > > (4) include main.js:
>
> > > >     Event.observe(window, 'load', function() {
> > > >         MYAPP.class1  = new MYAPP.Class1();
>
> > > Even if MYAPP exists at this point, the above won't work: the only
> > > native objects that can be used as constructors are function objects.
> > > MYAPP is and native object, it can't be used as a constructor as it
> > > doesn't have an internal [[consruct]] method (functions do).
>
> > Ooops, you're actually calling MYAPP.Class1 as a constructor, hey
> > nasty. You say the other script files don't to any instantiation, so
> > how do the MYAPP.Class1 and 2 properties get set?
>
> > --
> > Rob
--~--~---------~--~----~------------~-------~--~----~
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-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to