在网上找到的都是抄来抄去的,大致是这样:
[code="javascript"]//实现非AJAX提交表单一定要加下面的两行! onSubmit : Ext.emptyFn, submit : function() {
//再次设定action的地址
this.getEl().dom.action ='user.do?method=login'; this.getEl().dom.method = 'post';
//提交submit
this.getEl().dom.submit();
},[/code]
现在的问题是,4.0里好像没有.getEl()了……那么应该咋写啊?
我试着用AJAX方式提交的话,也有问题,报这样的错:
[img]http://dl.iteye.com/upload/attachment/482912/49a0d51a-3187-3155-ab7c-3f4ae7583271.png[/img]
感觉它好像把我的HTML内容试图用JSON方式解析出来?还是说我的后台返回的数据格式有问题?
我后台是ROR,写成这样:
[code="ruby"]
respond_to do |format|
format.html
format.xml { render :xml => @customers }
end
[/code]
就报那个错;如果写成这样:
[code="ruby"]
respond_to do |format|
format.html {render :json =>{"success"=>"ok"}.to_json}
format.xml { render :xml => @customers }
end
[/code]
就不报错了,但也不跳转页面……跳转页面难道是写在JS里的?之前3.x的时候我都是用的第一种写法它直接就跳转了的啊……
官网上的例子也都没有涉及到真正页面跳转的,照着API里的简单例子写成了这样,但还是不行:
[code="javascript"]
Ext.onReady(function() {
var submit_check = function(){
login_form.getForm().submit();
};
var login_form = Ext.create('Ext.form.Panel', {
url: '/login/login',
frame: true,
title: '请登录',
buttonAlign: "right",
width: 500,
bodyPadding: 5,
plain: false,
...
buttons: [{
text: 'Submit',
handler: submit_check,
formBind: true
}]
});
[/code]