[jQuery] Re: New to jquery, multiple .js files not running

2009-08-09 Thread Stephan Beal

On Aug 8, 7:25 pm, andrew.croce andrew.cr...@gmail.com wrote:
                 var current_section = $(this).attr(name);
...
                 $(#+current_section+_tab).addClass(current_tab);

This is wrong. The '#' searches by ID, not by name. Try (untested):

 var current_section = $(this).attr(id);



[jQuery] Re: New to jquery, multiple .js files not running

2009-08-09 Thread andrew.croce

What I was trying to do with  var current_section = $(this).attr
(name); was to create a variable that simply contained the name of
the particular subsection, which I could then attach to _tab to
pinpoint the currently selected tab.  I cant use the ID because it has
a different value, used for something else.  I used the name attribute
because it was convenient for creating that variable. Is this a bad
idea, could that be screwing up the whole file? or is the name
attribute inaccessible to jquery?

The bigger problem, it seems, is that nothing is running in that
gallery.js file, not even the first few lines...
$(.current_panel .image_area).removeClass(current_area);
$(.current_panel .image_area).hide();
$(.current_panel .intro).show();
$(.current_panel .intro).addClass(current_area);
$(.back_tab).hide();

These seem pretty straightforward to me and I don't understand why
theyre not working.  Im wondering if it cannot see the .current_panel
class, and hence cannot .hide() or .show() its children.  The
class .current_panel is added when a main menu btn is clicked, and the
script for that is in the other panels.js file, which, as I said, is
running perfectly. If all the javascript on the site is run on page
load, then there is no .current_tab class at the time, and hence
nothing will happen.  Is this a likely cause? and if so is there a way
to only run gallery.js once a menu btn is clicked? I tried adding the
contents of gallery.js to that click function in the other file, but
as I said, it broke the whole file.
Thanks,
Andrew

On Aug 9, 12:34 pm, Stephan Beal sgb...@googlemail.com wrote:
 On Aug 8, 7:25 pm, andrew.croce andrew.cr...@gmail.com wrote:

                  var current_section = $(this).attr(name);
 ...
                  $(#+current_section+_tab).addClass(current_tab);

 This is wrong. The '#' searches by ID, not by name. Try (untested):

                  var current_section = $(this).attr(id);


[jQuery] Re: New to jquery, multiple .js files not running

2009-08-09 Thread Stephan Beal

On Aug 9, 7:38 pm, andrew.croce andrew.cr...@gmail.com wrote:
 What I was trying to do with  var current_section = $(this).attr
 (name); was to create a variable that simply contained the name of
 the particular subsection, which I could then attach to _tab to
...
 idea, could that be screwing up the whole file? or is the name
 attribute inaccessible to jquery?

i see. No, it's not a bad idea, i was just confused by it.

 The bigger problem, it seems, is that nothing is running in that
 gallery.js file, not even the first few lines...
         $(.current_panel .image_area).removeClass(current_area);
         $(.current_panel .image_area).hide();
         $(.current_panel .intro).show();
         $(.current_panel .intro).addClass(current_area);
         $(.back_tab).hide();

If you haven't done so yet, install Firebug and enable it for your
page. Then click the Script -- Break on all Errors option and
reload your script. If there's a syntax error or something which is
causing an silent failure, this will normally point you directly to
it. Other than that, i don't have any tips.

 class .current_panel is added when a main menu btn is clicked, and the
 script for that is in the other panels.js file, which, as I said, is
 running perfectly. If all the javascript on the site is run on page
 load, then there is no .current_tab class at the time, and hence
 nothing will happen.

That's right - selectors match only what's currently in the dom at the
moment (but the new livequery API can also catch future matches). It
sounds like you've found the problem.


[jQuery] Re: New to jquery, multiple .js files not running

2009-08-09 Thread andrew.croce

Thanks for your replies, I appreciate it.

I put the contents of gallery.js inside the click function and it
appears to be working now.  I had tried this before, but there must
have been an unrelated syntax error or something that was causing it
to break.

Thanks
Andrew

On Aug 9, 4:45 pm, Stephan Beal sgb...@googlemail.com wrote:
 On Aug 9, 7:38 pm, andrew.croce andrew.cr...@gmail.com wrote:

  What I was trying to do with  var current_section = $(this).attr
  (name); was to create a variable that simply contained the name of
  the particular subsection, which I could then attach to _tab to
 ...
  idea, could that be screwing up the whole file? or is the name
  attribute inaccessible to jquery?

 i see. No, it's not a bad idea, i was just confused by it.

  The bigger problem, it seems, is that nothing is running in that
  gallery.js file, not even the first few lines...
          $(.current_panel .image_area).removeClass(current_area);
          $(.current_panel .image_area).hide();
          $(.current_panel .intro).show();
          $(.current_panel .intro).addClass(current_area);
          $(.back_tab).hide();

 If you haven't done so yet, install Firebug and enable it for your
 page. Then click the Script -- Break on all Errors option and
 reload your script. If there's a syntax error or something which is
 causing an silent failure, this will normally point you directly to
 it. Other than that, i don't have any tips.

  class .current_panel is added when a main menu btn is clicked, and the
  script for that is in the other panels.js file, which, as I said, is
  running perfectly. If all the javascript on the site is run on page
  load, then there is no .current_tab class at the time, and hence
  nothing will happen.

 That's right - selectors match only what's currently in the dom at the
 moment (but the new livequery API can also catch future matches). It
 sounds like you've found the problem.