Extjs 窗体未在窗口上提交
我使用以下代码创建了一个包含表单的窗口:Extjs 窗体未在窗口上提交,extjs,Extjs,我使用以下代码创建了一个包含表单的窗口: var confirm = new Ext.Window({ //xtype: 'form', hidden: true, id: 'FrmModalWindow', autodestroy: true, layout: 'aut
var confirm = new Ext.Window({
//xtype: 'form',
hidden: true,
id: 'FrmModalWindow',
autodestroy: true,
layout: 'auto',
bodyPadding: 10,
items: [
//
{xtype: 'form',
id: 'FrmModalConfirma',
autodestroy: true,
layout: 'auto',
bodyPadding: 10,
items: [
{
xtype: 'displayfield',
fieldLabel: 'Esta seguro que desea guardar los cambios y recalcular la categoría?',
labelWidth: 500
},
{
xtype: 'combobox',
width: 500,
name: 'id_motivo_modificacion',
allowBlank: false,
fieldLabel: 'Motivo de los cambios',
labelWidth: 150,
store: 'MotivoStore',
displayField: 'descripcion_motivo_modificacion',
valueField: 'id_motivo_modificacion'
},
{
xtype: 'textareafield',
width: 500,
name: 'observacion',
fieldLabel: 'Observaciones',
labelWidth: 150
},
{
xtype: 'textfield',
anchor: '100%',
itemId: 'hiddenFieldCedulaGeneral',
fieldLabel: 'Label',
name: 'cedula_estudiante',
hidden: true,
emptyText: cedulaGeneral.getValue()
},
{
xtype: 'textfield',
anchor: '100%',
itemId: 'hiddenFieldEstado',
fieldLabel: 'Label',
name: 'cod_estado',
hidden: true,
emptyText: 'MPA'
},
{
xtype: 'container',
layout: 'column',
items: [
{
xtype: 'button',
text: 'Si, recalcular',
listeners: {
click: function(){
/*********************************************
************* SUBMIT THE FORM ****************
*********************************************/
var formaGeneral = Ext.ComponentQuery.query("#FrmModalConfirma")[0];
console.log(formaGeneral);
if(formaGeneral.isValid()){
formaGeneral.submit(
{
url: '../servidor/sbs/informaciongeneral/duplicaultimoingreso',
success: function(response, opts){
console.log("Se duplicó con éxito");
},
failure: function(response,opts){
console.log("Error al duplicar");
}
});
}
/********************************************
************** DO A LOT OF OTHER STUFF ******
********************************************/
//CLOSE AFTER SAVING
var ventana = Ext.ComponentQuery.query("#FrmModalWindow")[0];
ventana.destroy();
/************************************************
If I change ventana.destroy() to ventana.hide(), the form does submit
*************************************************/
}
}
},
{
xtype: 'tbspacer',
width: 30
},
{
xtype: 'button',
text: 'No, cancelar',
listeners: {
click: function(){
//Cierra la ventana
var ventana = Ext.ComponentQuery.query("#FrmModalWindow")[0];
ventana.destroy();
/************************************************
If I change ventana.destroy() to ventana.hide(), the form does submit
*************************************************/
}
}
}
]
}
]
}
]
});
confirm.show();
因此,如果我将代码保留为ventana.destroy(),则创建的表单永远不会被提交,如果我将其更改为ventana.hide(),则表单确实会被提交,但如果用户继续使用调用该窗口的选项,它会创建窗口的多个副本。我不明白为什么在使用ventana.destroy()时找不到该表单 submit调用是异步的,如果您立即销毁它,它就不会到达服务器
您可以做的是立即隐藏表单,然后在成功/失败回调中销毁它。提交调用是异步的,如果您立即销毁它,它将永远不会到达服务器
您可以立即隐藏表单,然后在成功/失败回调中销毁它。非常感谢!这就是为什么这么想你!这就是问题所在