第一个对话框效果很好。这是我正在使用的方法:
HTML <div>
:
<div id="newarticle-form" title="Création nouvel article">
<form id="newarticleform" method="post" action="articles/ajout">
<fieldset>
<label for="validite" class="label-class">Date de validité</label>
<input type="text" name="validite" id="validite" size="10" maxlength="10" class="text input-class" />
<label for="libelle" class="label-class">Libellé</label>
<input type="text" name="libelle" id="libelle" size="50" maxlength="100" class="text input-class" />
<label for="email" class="label-class">Description</label>
<input type="text" name="description" id="description" value="" size="50" maxlength="250" class="text input-class" />
<label for="pu" class="label-class">Prix unitaire</label>
<input type="text" name="pu" id="pu" value="" size="10" maxlength="10" class="text input-class" />
</fieldset>
</form>
<p class="validateTips"></p>
</div>
Javascript jquery ui对话框:
$(function() {
$( "#newarticle-form" ).dialog({
autoOpen: false,
height: 'auto',
width: 700,
modal: true,
resizable:false,
buttons: {
"Ajouter article": function() {
.... here is the preparation of the submit ....
$("#newarticleform").submit();
$(this).dialog("close");
},
"Fermer": function() {
$(this).dialog( "close" );
}
}
});
$("#New") //The button to open the dialog
.click(function() {
$("#newarticle-form").dialog("open");
});
});
效果很好!
此页面有第二个jquery ui对话框。当我使用相同的方法(但不是相同的ID)添加它时,此对话框将打开并在大约一秒后关闭。
为什么?