enwise — 2011-12-17T01:48:55-05:00 — #1
I'm trying to add slideDown to http://jsfiddle.net/Jk59f/ so that it slides down smoothly if the dark area is not expanded and just refreshes the link if it is clicked or another link is clicked.
I haven't been able to figure it out though after testing multiple areas.. it just doesnt slide at all it just jumps!
How do I do this?
sdleihssirhc — 2011-12-17T02:17:52-05:00 — #2
The slideDown method only works when an element has display: none. So the following will do nothing:
But if you hide the element first, it suddenly works:
One of the most frustrating parts of the slideDown docs (and the jQuery docs in general) is that they don't mention this requirement ;_;
As far as where to put it, it can be anywhere after you insert the contentTobeLoaded HTML into the #ajax <div>. Of course, you'll still have to tinker with it, because there's an unsightly jump after the content is inserted and hidden, but before it actually slides...
Ah, you changed it so that the last sentence is actually moot. Good job! All you need to do is add the hide/slideDown calls and you're good.
enwise — 2011-12-17T02:35:57-05:00 — #3
did i place the slideDown in the wrong place?
sdleihssirhc — 2011-12-17T02:39:28-05:00 — #4
Nope, but you did forget to hide the element, first. Like this:
enwise — 2011-12-17T10:27:46-05:00 — #5
Ohh I see! you said
The slideDown method only works when an element has display: none
so is display: none and .hide() the same?
sdleihssirhc — 2011-12-17T12:38:54-05:00 — #6
Mostly. There's some special stuff that .hide() can do (if you give it a speed, then it animates the hiding; it makes sure to save what the old display was), but it ultimately sets each element's display to none.
enwise — 2011-12-17T12:53:06-05:00 — #7