2011-05-25 245 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"); 
    }); 
});