[jQuery] Re: using doc.ready in an external .js file

2008-07-08 Thread kgosser

Bingo, that was it. Big time "duh" noob moment :)

On Jul 8, 4:50 pm, Carl Von Stetten <[EMAIL PROTECTED]> wrote:
> kgosser,
>
> Are you loading jQuery.js after your main.js file?  If you are, try
> loading jQuery first, as it must be present before using any of its
> functions.
>
> Carl
>
> kgosser wrote:
> > Here's what I'm not getting about jQuery from a novice point of view.
> > Let's say I have this:
>
> >
> >$(document).ready(function() {
> >$("#switcherBtn").click(function(){
> >$("#target").toggleClass("nodisplay");
> >});
> >});
> >
>
> > I have a function to toggle the display of a certain div. This div is
> > on virtually all my pages, though, so instead of putting this in the
> > header of each page, I want to put it in a global include file, for
> > example main.js.
>
> > I don't understand why copying and pasting
>
> >$(document).ready(function() {
> >$("#switcherBtn").click(function(){
> >$("#target").toggleClass("nodisplay");
> >});
> >});
>
> > into main.js throws this error in Firebug:
>
> > $ is not defined
> > main.js()()main.js (line 1)
> > $(document).ready(function(){
>
> > Any input?


[jQuery] Re: using doc.ready in an external .js file

2008-07-08 Thread Carl Von Stetten

kgosser,

Are you loading jQuery.js after your main.js file?  If you are, try 
loading jQuery first, as it must be present before using any of its 
functions.

Carl

kgosser wrote:
> Here's what I'm not getting about jQuery from a novice point of view.
> Let's say I have this:
>
>   
>   $(document).ready(function() {
>   $("#switcherBtn").click(function(){
>   $("#target").toggleClass("nodisplay");
>   });
>   });
>   
>
> I have a function to toggle the display of a certain div. This div is
> on virtually all my pages, though, so instead of putting this in the
> header of each page, I want to put it in a global include file, for
> example main.js.
>
> I don't understand why copying and pasting
>
>   $(document).ready(function() {
>   $("#switcherBtn").click(function(){
>   $("#target").toggleClass("nodisplay");
>   });
>   });
>
> into main.js throws this error in Firebug:
>
> $ is not defined
> main.js()()main.js (line 1)
> $(document).ready(function(){
>
>
>
> Any input?
>
>
>