2013-05-29 110 views
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); 
    } 
}); 
+0

当您在此脚本之外访问该URL时,该URL是否有效?一个404是一个404 ...另外,第三个console.log()没有执行,我怀疑,因为你把它放在一个语法不正确的地方。传递给submit()的options参数是一个Object。 – existdissolve

+0

@existdisslove mmm服务器端脚本在应用程序之外运行。访问URL:http://sigetumed.cp/bin/paciente/modificar.php并在屏幕上显示“{'success':false,'msg':'Faltan llenar campos obligatorios'}”。很好。下面发表我的表单定义。 – ramiromd

+0

你应该检查你的表单的'submitUrl',问题就在那里。你也确定窗体有一个像'url'的属性;我不这么认为。再次检查[API](http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Panel)。 – talha06

回答

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(); 
       } 
      } 
     });