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:
<div id="main" class="x-layout-inactive-content">
<div style="width:400px;margin-left:180;margin-top:50">
<div class="x-box-tl"><div
class="x-box-tr"><div class="x-box-tc"></
div></div></div>
<div class="x-box-ml"><div
class="x-box-mr"><div class="x-box-mc">
<div id="form-ct"></div>
</div></div></div>
<div class="x-box-bl"><div
class="x-box-br"><div class="x-box-bc"></
div></div></div>
</div>
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---