jQuery UI ダイアログを使用して、さまざまな入力のエラーを表示したいと考えています。私の問題は、ダイアログ ボックスの機能を 1 つだけ定義し、ID と特定のエラー メッセージを含む複数の html に関連付けたいということです。
どうすればそれができますか?
現時点では、私はこれを持っています:
// 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;
});
1 つのメッセージの HTML は次のようになります。
<div id="dialog">
<p>The error message here.</p>
</div>