0

我有一个编辑用户表单。表单是使用以下代码从 Json 存储加载的:

    var store = Ext.create('cp.store.form.Paciente',{});
    store.load({params:{idUsuario: idPaciente}});
    var form = Ext.create('cp.view.form.EditPaciente',{
        action: 'bin/paciente/modificar.php'
    });
    // note: write this lines in the controller
    form.on('afterrender',function(form,idPaciente){
       form.getForm().loadRecord(store.first());
       form.getForm().findField('idUsuario').setValue(idPaciente);
    });
    var win = Ext.create('cp.view.ui.DecoratorForm',{
        aTitle: 'Editar paciente',
        aForm: form
    });
    win.show();

加载代码工作正常。提交代码为:

var me = this;
    console.log('Submit...');
    console.log(this.url);
    // WHY NOT SUBMIT !!!!
    this.getForm().submit({
        console.log('submit !');
        success: function(form,action){
            if(action.result.success === true){
                Ext.create('cp.view.ui.AlertOk',{mensaje:action.result.msg}).showDialog();
                me.up('decoratorForm').close();
            }else{
                Ext.create('cp.view.ui.AlertErr',{mensaje:action.result.msg}).showDialog();
            }
        }
    });

因此,提交代码开始运行。FireBug 显示第一个和第二个“console.log”,“this.url”值正确。但是,第三个“console.log”没有执行,表单也没有发送到服务器。Firebug 没有说“this.url”值的 404 错误。有任何想法吗 ?谢谢 !

添加表单定义:

Ext.define('cp.view.form.EditPaciente',{
    extend: 'Ext.form.Panel',
    alias: 'widget.editPaciente',


    bodyPadding: '5px 5px 5px 5px', 
    bodyStyle: 'border: none',
    fieldDefaults: {
        labelWidth: 65,
        labelAlign: 'top'
    },

    initComponent: function(){
        this.url = this.action,
        this.method = 'POST',
        this.items = [ .... ]
        this.callParent(arguments);
    }
});
4

1 回答 1

0

您不能将日志语句放在对象文字中。

  submit({                              <-- This is an object literal 
            console.log('submit !');    <-- This can not be in an object literal
            success: function(form,action){
                if(action.result.success === true){
                    Ext.create('cp.view.ui.AlertOk',{mensaje:action.result.msg}).showDialog();
                    me.up('decoratorForm').close();
                }else{
                    Ext.create('cp.view.ui.AlertErr',{mensaje:action.result.msg}).showDialog();
                }
            }
        });
于 2013-05-31T22:05:57.907 回答