Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: Bug In jQuery?

  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question Bug In jQuery?

    Hello,

    Please look into this code (or the attached file)

    When clicking on the button toggles the table to hide and then to show, it leaves an extra width on the table. (See screenshot for details)

    Is this a bug in jQuery? Can we overcome this?








    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript" src="jquery-1.2.6.js"></script>
    <script>
    	$().ready(function(){
    					   $("#mybtn").click(function(){
    										  
    										  $("#myid").slideToggle();
    										  });
    					   
    					   });
    </script>
    </head>
    <body>
    <input type="button" id="mybtn" value="Clicky" />
    <table width="50%" border="0" cellspacing="0" cellpadding="0" id="myid" bgcolor="#CCCCCC" align="center">
      <tr>
        <td align="center"><strong>Name</strong></td>
        <td align="center"><strong>City</strong></td>
        <td align="center"><strong>Coutry </strong></td>
        <td align="center"><strong>Telephone</strong></td>
        <td align="center"><strong>Designtion</strong></td>
      </tr>
      <tr>
        <td align="center">Paul</td>
        <td align="center">New York</td>
        <td align="center">US</td>
        <td align="center">111222333444</td>
        <td align="center">CEO</td>
      </tr>
      <tr>
        <td align="center">Adam</td>
        <td align="center">Chicago</td>
        <td align="center">US</td>
        <td align="center">11558899</td>
        <td align="center">Programmer</td>
      </tr>
    </table>
    
    </body>
    </html>

    Thanx
    Attached Files Attached Files

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    hi there,

    i think i have a solution to your problem the table width is set at 50% and wot the JQuery is doing is wrapping a DIV around it to match the current size, so the table is shrinking to 50% or is current size.

    The fix is to wrap the table in another DIV

    like this...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript" src="jquery-1.2.6.js"></script>
    <script>
    	$().ready(function(){
    					   $("#mybtn").click(function(){
    										  
    										  $("#table_wrapper").slideToggle();
    										  });
    					   
    					   });
    </script>
    </head>
    <body>
    <input type="button" id="mybtn" value="Clicky" />
    <div id="table_wrapper" style="width:100%;">
        <table width="50%" border="0" cellspacing="0" cellpadding="0" id="myid" bgcolor="#CCCCCC" align="center">
          <tr>
            <td align="center"><strong>Name</strong></td>
            <td align="center"><strong>City</strong></td>
            <td align="center"><strong>Coutry </strong></td>
            <td align="center"><strong>Telephone</strong></td>
            <td align="center"><strong>Designtion</strong></td>
          </tr>
          <tr>
            <td align="center">Paul</td>
            <td align="center">New York</td>
            <td align="center">US</td>
            <td align="center">111222333444</td>
            <td align="center">CEO</td>
          </tr>
          <tr>
            <td align="center">Adam</td>
            <td align="center">Chicago</td>
            <td align="center">US</td>
            <td align="center">11558899</td>
            <td align="center">Programmer</td>
          </tr>
        </table>
    </div>
    </body>
    </html>
    ave tested on FF3 and IE7 and it seems to work ok now

  • The Following 2 Users Say Thank You to mic2100 For This Useful Post:

    phantom007 (11-14-2008), rangana (11-13-2008)

  • #3
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Thanx

    that fixd

  • #4
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Question:

    How do you hide/unhide an entire row in a table using jQuery?

    Warpping it with a <DIV> didnt help

    Thanx

  • #5
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Question:

    How do you hide/unhide an entire row in a table using jQuery?

    Warpping it with a <DIV> didnt help

    Thanx

  • #6
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    I'm not certain what you mean, works fine at my end. Have you used the hide() method?

    Anyway, could you please up the codes involved.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    phantom007 (11-20-2008)

  • #7
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    can u have a button and click of that button use the slideToggle() function in jquery?

    Click on the button once or twice and see when it shows the row, the rows gets distorted.


    Thanx

  • #8
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Plz take a look into this code


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script language="javascript" src="jquery-1.2.6.js"></script>
    <script>
    	$().ready(function(){
    					   $("#mybtn").click(function(){
    										  
    										  $("#myid").slideToggle();
    										  });
    					   
    					   });
    </script>
    </head>
    <body>
    <input type="button" id="mybtn" value="Clicky" />
    <table width="50%" border="1" cellspacing="0" cellpadding="0" bgcolor="#CCCCCC" align="center">
      <tr>
        <td align="center"><strong>Name</strong></td>
        <td align="center"><strong>City</strong></td>
        <td align="center"><strong>Coutry </strong></td>
        <td align="center"><strong>Telephone</strong></td>
        <td align="center"><strong>Designtion</strong></td>
      </tr>
      <tr>
        <td align="center">Paul</td>
        <td align="center">New York</td>
        <td align="center">US</td>
        <td align="center">111222333444</td>
        <td align="center">CEO</td>
      </tr>
      <tr id="myid">
        <td align="center">Adam</td>
        <td align="center">Chicago</td>
        <td align="center">US</td>
        <td align="center">11558899</td>
        <td align="center">Programmer</td>
      </tr>
    </table>
    
    </body>
    </html>

  • #9
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    I would do it this way instead:
    Code:
    $("#myid").animate({opacity:'toggle'},'slow');
    The slideToggle() method toggles the display from hidden to block and vice versa instead of (hidden / inline-row).

    Tested:
    Code:
     $("#myid").css({display:'block'});
    ...the effect of having that code is the same as the problem you are experiencing.

    Not sure for a real fix, but I would change to animate() method instead and play with opacity as it's stable.

    Hope that makes sense.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #10
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts
    Hey


    Can u tell me what jQuery function are they using for that left slideshow? (click on the buttons saying "Gifts starting from"

    Code:
    http://www.isango.com/Gift.aspx

  • #11
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

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