2010-08-05 134 views
0

如何爲jQuery對話框定義備用關閉按鈕?jQuery對話框:備用關閉按鈕

我想用類「popup-close」的錨來關閉打開的對話框。

最簡單最好!

+0

什麼jQuery的對話是這樣嗎? – Reigel 2010-08-05 01:06:21

+0

jQuery UI。股票。 @TheCloudlessSky做了詭計! – 2010-08-05 01:59:25

回答

2

這應該做的伎倆:

<div id="dialog" title="Dialog Title" style="border: 1px solid red; position: absolute; display: none"> 
    I'm in a dialog 
    <span class="popup-close">CLOSE ME!</span> 
</div> 

<a id="open-dialog-button" href="#">Open Dialog</a> 

和你的jQuery ...

$("#dialog > .popup-close").click(function() { 
    $("#dialog").dialog("close"); 
}); 

$("#open-dialog-button").click(function() { 
    $("#dialog").dialog({ 
     // Disable close on escape and the default close button for this dialog. 
     closeOnEscape: false, 
     open: function(event, ui) { 
      $(".ui-dialog-titlebar-close", $(this).parent()).hide(); 
     } 
    }); 
});