问题描述
我有JQuery对话框用于在表中插入新行。一切都很好。几天前,当我插入FlexiGrid for Table时,我开始遇到问题。当我插入新的行对话框消失时,但是当我打开对话框时,插入的新插入数据仍然在对话框中。
I have JQuery dialog box for inserting new row in table. And everything works good. Few days ago when I inserted FlexiGrid for Table started a problem for me. When I insert new row dialog dissapear but when I open dialog for new insert data that is inserted before is still in dialog.
如何在完成对话框的使用后重置对话框字段。
How to reset dialog fields after I finish with it's usage.
对话框的代码如下:
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#newDialog-form" ).dialog({
autoOpen: false,
height: 250,
width: 300,
modal: true,
buttons: {
Salva: function() {
$.ajax({
url: 'agendaTipoAppuntamentoSaveJson.do',
type: "POST",
dataType: "json",
data: $("#newDialogForm").serialize(),
success: function(result) {
if (result.esito!='OK') {
alert(result.esito + ' ' + result.message);
}
else {
addNewTipoAppuntamento(
result.insertedTipoApp.idTipoAppuntamento ,
result.insertedTipoApp.codice,
result.insertedTipoApp.descrizione,
result.insertedTipoApp.descrBreve,
result.insertedTipoApp.colore
);
$("#newTable").flexReload();
$( "#newDialog-form" ).dialog( 'close' );
}
},
error:function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}
});
},
Annula : function() {
$( this ).dialog( "close" );
}
}
});
$( "#newDialog-form" ).dialog({ closeText: '' });
});
这是对话形式:
<div id="newDialog-form" title="Nuovo Tipo Appuntamento" class="inputForm" >
<form id="newDialogForm" action="agendaTipoAppuntamentoSaveJson.do" >
<input type="hidden" name="azione" id="idAzione" value="update" />
<input type="hidden" name="idTipoAppuntamento" id="idTipoAppuntamentoIns" value="-1" />
<fieldset>
<table>
<tr >
<td>
<label for="codiceIns">Codice </label>
</td><td>
<input type="text" name="codice" id="codiceIns" class="text ui-widget-content ui-corner-all"/>
</td></tr><tr>
<td>
<label for="descrizioneIns">Descrizione </label>
</td><td>
<input type="text" name="descrizione" id="descrizioneIns" value="" class="text ui-widget-content ui-corner-all" />
</td></tr><tr>
<td>
<label for="descrBreveIns">descrBreve </label>
</td><td>
<input type="text" name="descrBreve" id="descrBreveIns" value="" class="text ui-widget-content ui-corner-all" />
</td></tr><tr>
<td>
<label for="coloreIns">colore </label>
</td><td>
<input type="text" name="colore" id="coloreIns" value="" class="text ui-widget-content ui-corner-all" />
</td>
</tr>
</table>
</fieldset>
</form>
</div>
推荐答案
检查事件。你需要存储对话状态,状态将包括(标题,文本等),如果你正在修改它。
Check Dialog Close event. You will need to store the state of dialogue, state will include (title, text etc), if you are modifying it.
更新
阅读评论后,我得到了什么,并根据它给出答案。如果我错了,请纠正我。
After reading the comment, what I got, giving answer according to it. Please correct me if I'm wrong.
在打开dailog表单之前,将html存储到local变量然后在关闭它之前将html设置回对话框。
Before you open the dailog form, store the html to local variable and then before closing it set the html back to the dialogue.
var originalContent;
$("#newDialog-form").dialog({
//Your Code, append following code
open : function(event, ui) {
originalContent = $("#newDialog-form").html();
},
close : function(event, ui) {
$("#newDialog-form").html(originalContent);
}
});
希望这可以帮到你。
这篇关于我关闭它时从JQuery对话框中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!