2014-09-10 96 views

回答

2

beforeClose事件附加一個事件監聽器:

$("#dialog").on("dialogbeforeclose", function(event, ui) { 
    // do stuff, presumably return false to prevent closing the dialog 
}); 
+0

非常感謝。你能給我一個關於beforeClose事件的完整例子嗎? – 2014-09-10 14:23:30

+0

實際上沒有什麼需要補充的。 jQueryUI的文檔頁面提供了一個[簡單示例](http://api.jqueryui.com/dialog/#entry-examples)。你所要做的就是像上面那樣附加事件監聽器,或者用'beforeClose'選項傳遞它。請注意,dialogbeforeclose事件可能會冒泡,因此您可以在任何對話框的祖先中添加偵聽器。 – MaxArt 2014-09-10 14:42:50

0

你必須使用此代碼:

$(".selector").dialog({ 
    beforeclose: function(event, ui) { ... } 
}); 
+1

'時,作爲一個選項 – blgt 2014-09-10 14:43:36

+0

它是採取通過beforeClose'應在駝峯從這裏http://jquery-ui.googlecode.com/svn/tags/1.8.4/docs/dialog.html。看起來好吧 – 2014-09-10 16:06:08

+0

只有在該版本中:http://bugs.jqueryui.com/ticket/4669 – blgt 2014-09-10 16:10:24

相關問題