0
我想使用jQuery UI dialog來顯示不同輸入中的錯誤。我的問題是我想定義對話框的功能只有一個,但將其與包含一個id和一個特定的錯誤消息的幾個HTML關聯。如何使用相同的jQuery UI對話框?
我該怎麼做?
目前,我有這樣的:
// definition of the dialog, to do only once
$("#dialog").dialog({
autoOpen: false,
show: {effect: 'fade', speed: 100},
hide: {effect: 'fade', speed: 100},
modal: true,
resizable: false,
title: "Incorrect value",
buttons: { Ok: function() { $(this).dialog("close"); }},
beforeClose: function() { $("#time_at_address_years1").focus().val('') },
});
// the event, one per input
$("#time_at_address_years1").blur(function() {
$("#dialog1").dialog("open");
return false;
});
而且一個消息的HTML是這樣的:
<div id="dialog">
<p>The error message here.</p>
</div>
你是一個天才看看!不能相信它就是這麼簡單......簡單是最終的成熟。 我剛剛添加此行到您的函數,以便有效地打開框: \t $(selector).dialog(「open」); – 2012-08-08 11:26:49
不客氣。 – naden 2012-08-08 12:48:53