Extjs with rails form submit problem
I am creating a web application using EXT JS and Rails. I have a controller basic controller that contains the basic template ( master page ), clicking on the menu button would open a tab within tab panel and render some grid or form as required.
how to submit the form that is rendered from some other controller( for e.g : units controller) to the basic controller?
Code for Form submit that worked in separate project :
var sbtn=Ext.getCmp('btnSave');
sbtn.on('click',function(){
var frm=Ext.getCmp('myform');
frm.getForm().submit('/units/new', function() {
alert('Submit开发者_StackOverflow社区ted')
});
});
But when i use the same in my application it goes on to "basic/index" instead of "units/new" ?
Any Suggestion ??
I found solution to my own problem: I did it using JSON and Ajax.Request
var sbtn=Ext.getCmp('btnSave');
sbtn.on('click',function(){
var unitname = Ext.getCmp('unitname').getValue();
var description = Ext.getCmp('description').getValue();
var post_json = {"data": { "unitname" : unitname, "description" :description }};
var frm=Ext.getCmp('myform');
frm.getForm().submit(
Ext.Ajax.request({
url: '/units',
method: 'POST',
jsonData: post_json,
headers: {'Content-Type' : 'application/json' , 'Accept' : 'application/json'}
}))
});
精彩评论