jquery
  • modal-dialog
  • 2012-08-16 6 views 0 likes 
    0

    모달 대화 상자를 클릭하면이 링크가 나타납니다.첫 번째 링크 만 클릭하면 모달 대화 상자가 표시됩니다.

    <a href="#" id="addtoteam"> 
        Add to Team 
    </a> 
    

    이이 링크를 클릭 한 후 표시 될 대화 상자입니다

    $('#addtoteam').click(function(event){ 
         event.preventDefault(); 
         var url = '<?php echo BASEURL;?>'; 
         var teamID = '<?php echo $_SESSION['User']['Team']['id']?>'; 
         var playerID = $(this).attr('player-id'); 
         $("#dialogbox").dialog({ 
         autoOpen: true, 
         buttons: { 
            "Use Registration Credits": function(){ 
            // execute something here before redirecting it to another page, perhaps perform the updating of the registration_credits of each team here 
            window.location = url + '/administration/add_to_team/' + playerID +'/'+ teamID +'/?credit=1'; 
            }, 
            "Pay Extra Charge": function() { 
            //$(this).dialog("close"); 
            window.location = url + '/administration/add_to_team/' + playerID +'/'+ teamID +'/?proceed=1'; 
            }, 
            "Cancel": function() { $(this).dialog("close"); } 
           }, 
         width: 800 
         }); 
        }); 
    

    지금이 작동되지만 첫 번째 링크에서 작동합니다. 당신은 날 귀찮게 무엇

    `abc| def| ghi| Add to Teamlink` 
    `123| 456" 789| Add to Team link` and so on. 
    

    내가 abc| def| ghi| Add to Team link 링크를 클릭 할 때 모달 대화 상자가 나타납니다이다, 내 링크는 다음과 같습니다 링크가있는 모든 행에 대한 목록입니다 볼 수 있지만 나는 어떤 링크를 클릭하면 첫 번째 링크 이외의 상자는 나타나지 않습니다. 내 코드에서 문제가되는 것 같습니까? 감사.

    답변

    1

    '팀에 추가'링크를 모두 선택하려면 ID 대신 클래스 이름을 사용해야합니다.

    <a href="#" class="addtoteam"> 
        Add to Team 
    </a> 
    
    <a href="#" class="addtoteam"> 
        Add to Team 
    </a> 
    
    <a href="#" class="addtoteam"> 
        Add to Team 
    </a> 
    

    JS :이 작품

    $('.addtoteam').click(function(event){ 
        //code 
    }); 
    
    +0

    thanks.this works. :) –

    1

    당신이 더 많은 정보를 제공하지 않을 때문에 나는 당신의 문제가 당신의 모든 링크 (addtoteam)

    에 대해 동일한 id을 설정하는 것입니다 추측거야 id 그래서 당신이 사용해야 고유해야합니다 클래스 선택기 대신

    <a href="#" class="addtoteam"> 
        Add to Team 
    </a> 
    
    $('.addtoteam').click(function(event){....} 
    
    +0

    감사합니다 :).. 나는 두 가지 대답을 올바르게 받아들이지 않을까 두려워? hehe –

    +1

    @ CHiRiLo; 이봐, 도와 줘서 기뻐. –

    관련 문제