我有一個asp.net頁面,當用戶單擊保存按鈕時,數據庫在代碼隱藏中更新。保存完記錄後,我希望顯示固定秒數(例如5)的消息或對話框,然後讓它消失。或者如果用戶點擊它,它會消失。然後把它們留在他們所在的同一頁面上。jquery顯示當前對話框
謝謝。
我有一個asp.net頁面,當用戶單擊保存按鈕時,數據庫在代碼隱藏中更新。保存完記錄後,我希望顯示固定秒數(例如5)的消息或對話框,然後讓它消失。或者如果用戶點擊它,它會消失。然後把它們留在他們所在的同一頁面上。jquery顯示當前對話框
謝謝。
看看這個樣品,也許這將有助於:
if (condition == true) {
//Widen the scope of the myTimer variable
var myTimer;
//Open a jQuery dialog, requires the jQueryUI
//Create the dialog on the fly
$('<div id="myDialog"></div>').html('<p>Your content was saved!</p>').dialog({
'width' : 200,
'height' : 100,
'modal' : true,
'open' : function() {
//Set a timer which will automatically close the dialog in 5 sec
myTimer = setTimeout(function() {
//Close then remove the dialog
$('#myDialog').dialog('close').remove();
}, 5000); //Close in 5000 ms (5 sec)
},
'close' : function() {
//For extra security, clear the timer when the dialog is closed
clearTimeout(myTimer);
},
'buttons' : {
'Ok' : function() {
$(this).dialog('close').remove();
}
}
//Check out http://docs.jquery.com/UI/Dialog for more customize options
});
}
我沒有測試上面的代碼,但它應該工作,如果您自定義它爲您的需求。
希望幫助,
spryno724
只是回答你的第二個問題,如何使整個對話框消失,如果被點擊的任何部分。只需要添加另外的jQuery塊:
$('#myDialog').live('click', function() {
//Close the dialog
$(this).dialog('close').remove();
//Remove the timer
clearTimeout(myTimer);
});
同樣,我還沒有測試它,但它應該工作。
只需在上面顯示的另一個較大的jQuery塊之後直接添加上面的塊。
希望幫助,
spryno724
輝煌,謝謝。 – tim 2011-04-28 18:51:33
那麼問題出在哪裏? – Bakudan 2011-04-28 16:13:22
尋找在谷歌jQuery的彩盒,你會得到你所需要的,我猜。 – Bene 2011-04-28 16:15:22