SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery toggle keeps repeating on the second tab.

    here is my code:
    Code JavaScript:
    // hide the content
      $(".maintitles_jd").hide();
     
      $(".dad h3").click(function(){
        $(this).next(".maintitles_jd").stop(true, true).slideToggle()
         .siblings(".maintitles_jd:visible").stop(true, true).slideUp();
        $(this).stop(true, true).toggleClass("active");
        $(this).siblings(".dad h3").removeClass("active");
      });
    });

    The code above is working fine on the first tab, but when a second tab is generated and when clicked on toggle div it keeps repeating.

    Help!
    Last edited by cpradio; Apr 16, 2013 at 08:05. Reason: Added tags

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,895
    Mentioned
    212 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Could you possibly post a link to a page where I can see the problem?
    Also, what do you mean, "when a second tab is generated?"

    Sure it won't be too hard to sort out

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can not send you a link to the site as its confidential, but here are the code that im tryin to archive:





    Code JavaScript:
    $(document).ready(function(){
     
    	// hide the content
      $(".maintitles_jd").hide();
     
      $(".dad h3").click(function(event){
    		event.stopPropagation();
        $(this).next(".maintitles_jd").stop(true, true).slideToggle()
         .siblings(".maintitles_jd:visible").stop(true, true).slideUp();
        $(this).stop(true, true).toggleClass("active");
        $(this).siblings(".dad h3").removeClass("active");
      });
    });



    PHP Code:
    <?php 
            
                    
    require_once("../php_engine/_php_xml.php");
                    
                    if( isset(
    $_POST["qsurvey"]) && isset($_POST["qjobnumber"]) ){
                        
    $x = new aj_xml($_POST["qsurvey"],$_POST["qjobnumber"]);
                    }else{
                        
    $x = new aj_xml('LOCL','10.02',true);
                    }
                    
                    if(
    $x->file_does_exist == true){                    
                        
    $title_txt "Job Description";
                        
                        echo(
    "<div class='dad'>");
                        echo(
    "<h3 id='jd'>" $title_txt "</h3>");
                        echo(
    "<div class='maintitles_jd' id='jd_content' style='display: none'>");
                        
                        
    $x->readxml_jd();                                
                        
                        if(isset(
    $x->values)){
                            foreach(
    $x->values as $key=>$value){
                                if(
    $value!=''){
                                    if( 
    is_numeric($key) ){
                                        echo 
    "<p class='lines'>" $value "</p>";
                                    }

                                    if( !
    is_numeric($key) ){
                                        echo 
    "<div class='lines'><span class='heading_jd'>" $key"</span>" $value "</div>";
                                    }
                                }
                            }
                        }    
                                    
                            echo(
    "</div>"); // end of jd_content DIV
                            
    echo("</div>");// end of dada DIV    

                    
    }// end if($x->file_does_exist == true)
    ?>
    Last edited by cpradio; Apr 17, 2013 at 11:05. Reason: Added javascript and php tags

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,895
    Mentioned
    212 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by joeboo View Post
    I can not send you a link to the site as its confidential, but here are the code that im tryin to archive
    Fair enough, but I can't do very much with the PHP you posted.
    Would it be possible for you to navigate to the page you are having trouble with, then look at the source code (Ctrl + U in most browsers), copy it and post it here?
    I just need to be able to reproduce the problem you are having.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •