admin管理员组文章数量:1356905
I'm getting started with ExtJs. I'm building a very simple login form:
Ext.onReady(function () {
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var loginForm = new Ext.form.FormPanel({
url: '/Account/Login',
monitorValid: true,
labelWidth: 75,
frame: true,
title: 'Login',
width: 250,
defaultType: 'textfield',
defaults: { allowBlank: false },
items:
[{ fieldLabel: 'Username', name: 'username' },
{ fieldLabel: 'Password', name: 'password', inputType: 'password'}],
buttons:
[{
text: 'Login',
formBind: true,
handler: function (btn, evt) { /* how do i submit the form? */ }
}]
});
loginForm.render(document.body);
loginForm.el.center();
});
As you can see in the login button's handler function, I'm not quite sure how to submit the form. I have been pouring through the API documentation and have found some information about using the FormPanel's internal BasicForm submit method, but I'm not quite sure how to get at it. What am I missing?
I'm getting started with ExtJs. I'm building a very simple login form:
Ext.onReady(function () {
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var loginForm = new Ext.form.FormPanel({
url: '/Account/Login',
monitorValid: true,
labelWidth: 75,
frame: true,
title: 'Login',
width: 250,
defaultType: 'textfield',
defaults: { allowBlank: false },
items:
[{ fieldLabel: 'Username', name: 'username' },
{ fieldLabel: 'Password', name: 'password', inputType: 'password'}],
buttons:
[{
text: 'Login',
formBind: true,
handler: function (btn, evt) { /* how do i submit the form? */ }
}]
});
loginForm.render(document.body);
loginForm.el.center();
});
As you can see in the login button's handler function, I'm not quite sure how to submit the form. I have been pouring through the API documentation and have found some information about using the FormPanel's internal BasicForm submit method, but I'm not quite sure how to get at it. What am I missing?
Share Improve this question asked Oct 5, 2010 at 16:34 Ronnie OverbyRonnie Overby 46.5k74 gold badges272 silver badges350 bronze badges1 Answer
Reset to default 5This works:
Ext.onReady(function () {
Ext.QuickTips.init();
// turn on validation errors beside the field globally
Ext.form.Field.prototype.msgTarget = 'side';
var loginForm = new Ext.form.FormPanel({
url: '/Account/Login',
monitorValid: true,
labelWidth: 75,
frame: true,
title: 'Login',
width: 250,
defaultType: 'textfield',
defaults: { allowBlank: false },
items: [
{ fieldLabel: 'Username', name: 'username' },
{ fieldLabel: 'Password', name: 'password', inputType: 'password'}
],
buttons: [
{
text: 'Login',
formBind: true,
handler: function (btn, evt) { loginForm.getForm().submit(); }
}
]
});
loginForm.render(document.body);
loginForm.el.center();
});
I didn't do this at first because referencing the formPanel variable while building the object felt weird, but I think it's ok to do it within a callback function.
本文标签: javascriptExtJs FormPanelHow to submit form using buttons declared inlineStack Overflow
版权声明:本文标题:javascript - ExtJs FormPanel - How to submit form using buttons declared inline? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743958760a2568625.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论