2011-09-27 6 views
1

'경고'링크를 클릭하면 메시지가 한 번만 표시됩니다 ().입니다. 이상하게도 링크 '대화'를 클릭하고 '경고'링크를 클릭하면 메시지가 두 번 연속으로 표시됩니다. 입니다.이상한 팝업 동작

메시지를 한 번만 표시하도록 수정하려면 어떻게해야합니까?

HTML

<p id="test"><a href="#">alert</a></p> 
<a href="#" onclick="showDialog()">dialog</a> 

jQuery를

$(function() { 
    $("p#test a").click(function() { 
    alert('alert'); 
    }); 
} 

function showDialog(){ 
    $("<div class='popupDialog'>Loading...</div>").dialog({ 
    closeOnEscape: true, 
    height: 'auto', 
    modal: true, 
    title: 'About Ricky', 
    width: 'auto' 
    }).bind('dialogclose', function() { 
    jdialog.dialog('destroy'); 
} 

답변

0

이 스크립트를 시도 할 수 있습니다.

<script type="text/javascript"> 

$(document).ready(function() { 

     $("p#test a").click(function() { 
      alert('alert'); 
     }); 
    }); 


    function showDialog1() { 
     $("<div class='popupDialog'>Loading...</div>").dialog()({ 
      closeOnEscape: true, 
      height: 'auto', 
      modal: true, 
      title: 'About Ricky', 
      width: 'auto' 
     }).bind('dialogclose', function() { 
      $(this).dialog('destroy'); 
     }); 
    } 
<script> 
+0

고맙습니다! 성공하지 않고'$ (document) .ready'로 이미 이것을 시도했습니다. – shub