2011-05-25 447 views
1

這裏是jQuery的的代碼來打開/關閉對話框和HTML鏈接:無法關閉jQuery UI的對話框

$("#security-code-link").click(function() { 
    $("#security-code-box").dialog({ 
     draggable: false, 
     height: 500, 
     modal: true, 
     position: ["center","center"], 
     resizable: false, 
     width: 500 
    }); 
}); 

$("#close-security-code-link").click(function() { 
     $("#security-code-box").dialog("close"); 
}); 


<a id="security-code-link">Where is this?</a> 
<div id="security-code-box"> 
<h3>Where is my security code?</h3> 
<div class="center"> 
    <img src="<?php bloginfo("template_directory"); ?>/images/security-codes.jpg" /> 
    <br /><a id="close-security-code-link">Close this box</a> 
</div> 
</div> 

爲什麼對話框不關閉?

+0

它的工作對我來說: http://jsfiddle.net/G9GY8/2/ 使用FF4,什麼瀏覽器您使用? – 2011-05-25 20:29:08

回答

1

試試這個:

$(function() { 
    $("#security-code-box").dialog({ 
     draggable: false, 
     height: 500, 
     modal: true, 
     position: ["center","center"], 
     resizable: false, 
     width: 500, 
     autoOpen: false 
    }); 
    $("#security-code-link").live('click', function() { 
     $("#security-code-box").dialog('open'); 
    }); 
    $("#close-security-code-link").live('click', function() { 
     $("#security-code-box").dialog("close"); 
    }); 
});