SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: click ID problem

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    May 2012
    Posts
    635
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    click ID problem

    Hi, I am getting trouble with this,my problem is that I have a div as a container,and a tabs compose of two li's ,every time i click Tab A the data will be request to the server via jQuery.ajax and then the requested data will be loaded to the container div,and if i click the Tab B the data also will be requested to the server via jQuery.Ajax and will be loaded to the container div...each Tab A and Tab B has dialog box if ever i click the edit button and then i already clicked the Tab B,the dialog of the Tab B will show as animated. And if i click to Tab A and then click again the edit button the dialog box of Tab A will show as animated.but my problem is that the two dialog will show every time i click the button edit.but i already changing the id of my edit button everytime i click each of this Tab.




    Code:
    $(function () {
    
        $('#TabA').click(function () {
    
    	$('#Bedit').attr('id','edit'); changing the id of the edit button
    
            $.ajax({
                type:"POST",
                url:"to other page.php",
                data:some parameter here //
                success:function (item) {
                  //data loaded to the container div here.                 
    
                    });
                }
    
            });
    
    
        });
    
    });

    Code:
       $('#TabB').click(function () {
    
    	$('#edit').attr('id','Bedit'); changing the id of the edit button
    
            $.ajax({
                type:"POST",
                url:"to other page.php",
                data:some parameter here //
                success:function (item) {
                  //data loaded to the container div here.                 
    
                    });
                }
    
            });
    
    
        });
    
    });
    HTML Code:
     <div  id="tabA" ></div>
     <div  id="tabAbox" >
        <div class="outerlabel">
            <label>Edit tab A</label>
        </div>
    
     </div>

    HTML Code:
      <div  id="tabB" ></div>
     <div  id="tabBbox" >
         <div class="outerlabel">
            <label>Edit tab B</label>
        </div>
    
     </div>

    Code:
    $(function(){
         $('#Bedit').click(function(e){
              e.preventDefault();
              $('#tabB').fadeIn(200);
              $('#tabBbox').animate({
                  top:'5px',
                  left:'250px'
              }, 500);
    
          });
    
    });
    Code:
    $(function(){
         $('#edit').click(function(e){
              e.preventDefault();
              $('#tabA').fadeIn(200);
              $('#tabAbox').animate({
                  top:'5px',
                  left:'250px'
              }, 500);
    
          });
    
    });

  2. #2
    SitePoint Guru
    Join Date
    May 2012
    Posts
    635
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I forgot to post the image button

    HTML Code:
    <div >
    
    <a href="#" id="edit"><img src="img/edit.png"/></a>
    
    </div>
    I found out that after clicking the TabB when i inspect to the firebug console tab the id="edit" change to id="Bedit" but when i look in the script tab of firebug the id="edit" still remains,
    i think this is the reason why the two of the dialog box will be triggered,is there anyways to solve this problem?

    Thank you in advance.

  3. #3
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,441
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    Hi jemz,

    Would it be possible that you post a demo of this somewhere?
    As it is, it is a bit hard to work out what is happening where.
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  4. #4
    SitePoint Guru
    Join Date
    May 2012
    Posts
    635
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi pullo, I don't know where i can show the demo

  5. #5
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,441
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jemz View Post
    Hi pullo, I don't know where i can show the demo
    So you are developing locally, right?
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  6. #6
    SitePoint Guru
    Join Date
    May 2012
    Posts
    635
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup,

  7. #7
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,441
    Mentioned
    39 Post(s)
    Tagged
    1 Thread(s)
    OK.
    Well, did you get this particular problem sorted out already, or does the issue still persist?
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  8. #8
    SitePoint Guru
    Join Date
    May 2012
    Posts
    635
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but i change the logic on clicking the id.
    thank you

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
  •