2011-04-21 3 views
0

jQuery가 "법적"링크를 클릭하는 이유는 무엇입니까? 그것은 HTML>jQuery 모달 창이 두 번째 링크에서 실행되지 않습니까?

<div id="top_function"> 
    <div class="functions" style="margin-top:7px;"><img src="img/addProfIcon.png" width="32" height="32" /> 
     <h4><a href="#?w=500" rel="popup_name" class="poplight">Add...</a></h4><!-- ADD PROF/COURSE --> 
    </div><!--function1--> 
    <!--<div class="functions"><img src="img/disclaimerIcon.png" width="32" height="32" /><h4><a href="#">Compare</a></h4></div>--> 
    <div class="functions"><img src="img/disclaimerIcon.png" width="32" height="32" /> 
     <h4><a href="#?w=500" rel="popup_name2" class="poplight2">Legal</a></h4> 
    </div><!--function3--> <!-- LEGAL --> 
    <div class="functions"><img src="img/contactIcon.png" width="32" height="32" /><h4><a href="#">Contact</a></h4></div><!--function4--> <!-- CONTACT --> 
</div> 

Modal.js>

$(document).ready(function() { 
$('a.poplight[href^=#]').click(function() { 
    var popID = $(this).attr('rel'); //Get Popup Name 
    var popURL = $(this).attr('href'); //Get Popup href to define size 

    //Pull Query & Variables from href URL 
    var query= popURL.split('?'); 
    var dim= query[1].split('&'); 
    var popWidth = dim[0].split('=')[1]; //Gets the first query string value 

    //Fade in the Popup and add close button 
    $('#' + popID).fadeIn().css({ 'width': Number(popWidth) }).prepend('<a href="#" class="close"><img src="img/close.png" class="btn_close" title="Close Window" alt="Close" /></a>'); 

    //Define margin for center alignment (vertical horizontal) - we add 80px to the height/width to accomodate for the padding and border width defined in the css 
    var popMargTop = ($('#' + popID).height() + 80)/2; 
    var popMargLeft = ($('#' + popID).width() + 80)/2; 

    //Apply Margin to Popup 
    $('#' + popID).css({ 
     'margin-top' : -popMargTop, 
     'margin-left' : -popMargLeft 
    }); 

    //Fade in Background 
    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag. 
    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer - .css({'filter' : 'alpha(opacity=80)'}) is used to fix the IE Bug on fading transparencies 

    return false; 
}); 

//Close Popups and Fade Layer 
$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer... 
    $('#fade , .popup_block').fadeOut(function() { 
     $('#fade, a.close').remove(); //fade them both out 
    }); 
    return false; 
}); 
}); 

.. "추가 ..."링크 작동 실제 (지금은) 모달 창 내용 :

테스트

답변

0

은 당신은 클래스 poplight와 앵커 태그의 클릭 핸들러를 설정합니다. 귀하의 '합법적 인'링크는 대신 poplight2 클래스를가집니다.

+0

쉽지는 않지만 각 클래스와 div에는 자체 데이터 세트가 있습니다. poplight (2x)를하면 같은 데이터 세트를 표시합니다. – Jshee

+0

@ user700070 : 응? 나는 왜 당신의 코드가 "작동하지 않는"지를 설명 할 뿐이다. 위의 불일치가 있습니다. –

+0

음,'poplight2'는 이유가 있습니다. 왜냐하면 각 링크가 다른 내용으로 새로운 모달 창을 팝업하므로'poplight'의 내용이'poplight2'와 다릅니다. – Jshee

관련 문제