HTML Code:
var loginObj = Class.create();
loginObj.prototype = {
initialize : function() {
Ext.onReady(this.create.bind(this), this, true);
},
create : function() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
this.fs = new Ext.form.Form({
labelAlign: 'right',
labelWidth: 85,
url:'index.php',
method: 'POST',
buttonAlign: 'right',
baseParams: {module:'login'}
});
this.fs.fieldset(
{legend:'Login'},
new Ext.form.TextField({
fieldLabel: 'Username',
name: 'username',
id: 'username',
allowBlank:false,
blankText: 'Required!',
width:190
}),
new Ext.form.Field({
autoCreate : {tag: "input", type: "password", autocomplete: "off"},
cls: 'x-form-text',
fieldLabel: 'Password',
name: 'password',
id: 'password',
allowBlank:false,
blankText: 'Required!',
width:190
})
);
this.fs.addButton('Login',this.doLogin.bind(this));
this.fs.render('form-ct3');
},
doLogin : function() {
this.fs.submit({
success: function(){
// do something?
window.location.reload();
},
waitMsg : 'Logging in...',
method: 'POST'
});
}
};
var login = new loginObj();
Note: this.<functionname>.bind(this) is prototype feature.
But in this case: this.fs.submit() posts (over XHR) the form data to the 'url' URL. (See the form constructor!).
Or, here is another example:
http://extjs.com/forum/showthread.php?t=4403