PDA

View Full Version : Login Page Submit Problem



bhangale.parag
21 Jan 2009, 7:54 AM
Hi all,
I have one problem regarding to login page of extJs. In that Login page i have made one Formpanel in that usename textfield and password field one login button and one cancel button .
when i enter the vale in username and password but on enter click the login button is not clicked so how can i handle that.???? can i want to handle the key event or any other way for this ????
Please help me.........
Waiting for Reply........
Thanks ,
Parag

mjlecomte
21 Jan 2009, 10:03 AM
You need to use a KeyMap to bind the enter button. For inspiration:



setKeymap: function() {

// map multiple keys to multiple actions by strings and array of codes
var map = new Ext.KeyMap(
this.el,//the element to bind to
[//the config object
{
//key: 13, // or Ext.EventObject.ENTER
//key: "a\r\n\t",
key: [10,Ext.EventObject.ENTER],//string or array of keycodes to handle
ctrl:false,//true = handle only when ctrl is pressed (default=F)
alt:false,//true = handle only when alt is pressed (default=F)
shift:false,//true = handle only when shift is pressed (default=F)
scope: this,//scope of callback function
fn: this.handleKeys//handler function called
}
],
"keydown"//optionally specify the event to bind to (default = "keydown")
);

},

// this function manages the key events
handleKeys: function(key, e) {

e.preventDefault();
var target = e.getTarget();

switch(key) {
case Ext.EventObject.ENTER:
if (this.getForm().isValid()) {
this.onButtonClick();
}else{
return false;
}
}
},

/**
* Button click handler
*/
onButtonClick: function() {
this.submit();
},

bhangale.parag
22 Jan 2009, 5:27 AM
THanks for quick reply,
but i dont understand this function i have to added in formpanel so directly i can press the enter and the submit function is called?????????
I dont understand it please can u elaborate it................
please sorry for that....
waiting for reply..........
thanks,
parag

xcoiax
22 Jan 2009, 6:11 AM
parag,

Can you please rephrase your question. I'm sorry, but I am a bit confused with your question. What actually are you trying to achieve with your login button?