PDA

View Full Version : How to make a jquery slide script work uniquely on multiple none unique divs?


Tomi
03-11-2009, 11:47 PM
I'm trying to use a jquery script on a social networking website I'm developing so the users can reply to comments left on their profile. The comment will display and below it it will say "Reply to this comment". When this is clicked the div will slide down with a form in it to reply with. The problem being all the scripts that I can find work just once on every page. If a persons profile already had multiple comments the script wont work properly.

How can the script be modified so when clicking "Reply to this comment" under the specified comment it will make the div slide down under that comment and not just the first one.

The script I'm using:

http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html

Thanks

Eldarrion
03-11-2009, 11:55 PM
The link you're giving doesn't work (Instead it leads to a site that looks a bit fishy... unless of course that was the intention to begin with). Also, it would help to see exactly how the specific comments are generated, because I personally doubt it would work just by altering the plug-in without knowing the structure of your website.

Tomi
03-12-2009, 01:26 AM
Sorry wrong link it's actually: http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html

I can't show you the structure of the site just yet as the php is still being coded but when its done ill put it up here.

Eldarrion
03-12-2009, 07:54 AM
Not really a whole lot of script there:


$(document).ready(function(){

$(".btn-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active"); return false;
});


});


Can easily be altered, but once again... we do need to see some HTML mark-up and how your divs or whatever are generated. Do they have a class? Are they child elements of others, etc, etc. It does help knowing the structure. For instance, if we're talking about a sibling, rather than a child element, it would be something like:


$("~ *" + this + ":not(visible)").slideToggle("slow"); // not 100% sure about the selector and a bit too late right now to test, so... forgive me if it's not exact.


But this is just a guess without site structure...