Sorry to my poor english.
I’m just beginning to use Extjs with Rails.There is problem with the
form submit.
Here is the rhtml code:
Here is the js coe:
- ================ Simple form =======================
*/
var simple = new Ext.form.Form({
labelWidth: 75, // label settings here cascade unless overridden
action:’/entry/create/’
});
simple.add(
new Ext.form.TextField({
fieldLabel: ‘name_native’,
name: ‘enterprise[name_native]’,
width:175
}),
new Ext.form.TextField({
fieldLabel: ‘name_eng’,
name: ‘enterprise[name_eng]’,
width:175
}),
new Ext.form.TextField({
fieldLabel: ‘address’,
name: ‘enterprise[address]’,
width:175
}),
new Ext.form.TextField({
fieldLabel: ‘tel’,
name: ‘enterprise[phone]’,
width:175
}),
new Ext.form.TextField({
fieldLabel: ‘http’,
name: ‘enterprise[http]’,
width:175
}),
new Ext.form.TextField({
fieldLabel: ‘email’,
name: ‘enterprise[email]’,
width:175
})
);
simple.addButton(‘Save’,function(){
simple.submit({ success:function(){alert(‘success’);},
failure:function(){alert(“failure”);
} });});
simple.addButton(‘Cancel’);
simple.render(‘form-ct’);
}}
}();
Ext.EventManager.onDocumentReady(index.init,index)
And here is the rails code:
class EntryController < ApplicationController
def index
end
def new
@enterprise=Enterprise.new
end
def create
@enterprise=Enterprise.new(@params[:enterprise])
if @enterprise.save
redirect_to(:action=>‘index’)
else
render_action ‘new’
end
end
end
but each time,the code always alert “failure” ,and the data is wroten
to the database successfully.I don’t know what happend.The correct
resualt is the page will redirect to
another page.