views:

381

answers:

3

1 - I used to prevent the default action of an anchor tag upon click by doing the following...

$('a').click(function() { /*stuff*/   return false; });

But then I decided to condense code by declaring a function that I could call within the click method since I use the same block of code elsewhere. So now it looks like...

$('a').click(myFunc(var1, var2));

And even though the last line of myFunc is 'return false;' the links still go through. What am I doing wrong here?

2 - The slideDown() function in jQuery doesn't seem to be animating quite right. The way I've seen it is that the box reveals itself by stretching or falling downwards. The top of the box is stationary while the bottom moves and stretches down. The way that I'm seeing it animate however is that the box starts off as a thin rectangle and both top and bottom stretch up and down, respectively, until the box is at its appropriate dimensions. Is there a certain setting I need? Is maybe my CSS influencing this?

3 - I'm getting a laundry list of Javascript warnings in my console (using Firefox 3.6 with Firebug and Web Developer add-ons) and they all come from jquery.min.js. I've seen

  • Reference to undefined property e[b] line 38
  • Reference to undefined property a[++e] line 30
  • Reference to undefined property f.queue line 136
  • Reference to undefined property f[b] line 113

And more.

http://schnell.dreamhosters.com/folio/
This is the website I'm working on.

+4  A: 

About your first issue, when you assign the click handler, you are making a function call immediately, the return value will be assigned as the click handler.

That will only work if the returned value of myFunc is actually another function:

function myFunc(var1, var2) { // capture var1 and var2 arguments
  return function (e) { // the actual event handler
    // var1 and var2 available here...
    return false;
  };
}

$('a').click(myFunc(var1, var2));
CMS
What if I did... $('a').click(function (){ myFunc(var1, var2); return false; });myFunc has no return value, it's only a set of jQuery methods for manipulating the DOM with a bit of AJAX.
Mathias Schnell
Just tried what I thought and it works perfectly. Thanks for the guidance! Now if I could just get slideDown() and slideUp() to animate correctly...
Mathias Schnell
A: 

for your 3rd question, normally when you get alotta errors, it's alot easier to use actual jquery (not minified I mean) so you see which functions aren't working right

hakim-sina
They aren't errors really, just warnings, but I'll try giving the full version a whirl.
Mathias Schnell
I did a bit of research and apparently a lot of warnings are normal for jQuery and it's more of a Firefox issue if you have a setting called 'javascript.options.strict' set to 'true'. Supposedly having this setting to 'true' is uncommon and having it set to this makes it produce a LOT of warnings that will slow you down. In light of this I simply decided to change this setting to 'false' and I would assume most people do as well. Ever since then, no warnings. I imagine the jQuery developers know this issue quite well and are either working to fix it or know it's really not an issue.
Mathias Schnell
A: 

for your second question, can you be more specific which box is not sliding down correctly ? because the boz on top left seems fine to me. is it the boix in the middle ?

hakim-sina
The box of information off to the right of the center of the page. It's right next to the picture at the center and says things like 'Equitoral Radius' and such
Mathias Schnell
And that's the only one with a slide down effect right now.
Mathias Schnell