EXT 4中的非AJAX表单提交,纠结了一下午的问题

来源:互联网 发布:input name 数组 编辑:程序博客网 时间:2024/06/06 02:46

看一下,EXT中Form的结构, 先是有Form.Basic,然后有子类Form.Panel.也就是一个Form容器,在我们提交的时候 yourForm.getForm().submit()就可以了,但这里默认的提交方式是AJAX提交,到后台后,要处理一个后台返回的JSON串的,如果你想使页面跳转,这里你就会得到一个异常,"you're tring decode an invalid JSON String",因为Server端返回的实际是个HTML,

看看API里有这样一个东西


standardSubmit

A class which handles submission of data from Forms using a standard <form> element submit. It does not handle the response from the submit.

Instances of this class are only created by a Form when submitting, when the form's Ext.form.Basic.standardSubmit config option is true.


标准提交,只要在Form代码里加上standardSubmit : true,到这里应该就完事,但是居然不好用,于是继续查,终于在Form.Panel里又找到下边这段:


Note: If subclassing FormPanel, any configuration options for the BasicForm must be applied to the initialConfigproperty of the FormPanel. Applying BasicForm configuration settings to this will not affect the BasicForm's configuration.


正好我的Panel就是自己重定义的,继承了Form.Panel,所以....你还得把这个属性放到initialConfig里..

原创粉丝点击