Results 1 to 3 of 3

Thread: EventObject.Enter and Button Click

  1. #1
    Sencha User prabhat2486's Avatar
    Join Date
    Apr 2010
    Location
    Sydney, Australia
    Posts
    39

    Default EventObject.Enter and Button Click

    Dear All,

    I have designed a Window which contains two button OK and Cancel. I have added key i.e. Ext.EventObject.ENTER for OK button function. This means same handler function i have linked in Key section and button config section section. When i press Enter button my form gets submittes because OK button function is linked with Enter key press. But when i tab to OK button and then press Enter button from key board, my handler function gets called twice. Once for Enter button pressed and second for OK button because i pressed Enter button when my tab was present at OK button.

    But it should be called once.

    Below are some code excerpts:

    openDayWisePwdExpiryFormWin : function(btn){
    this.resetPwdFormWin = new Ext.Window({
    title:'Change Login Password',
    width: 420,
    animateTarget:'workstation-tab-panel',
    animCollapse:true,
    autoHeight: true,
    modal:true,
    closable:false,
    keys:[{
    key: Ext.EventObject.ENTER,
    scope: this,
    handler: this.onResetExpiryPwdFormDlgClickOk

    },{
    key: Ext.EventObject.ESC,
    handler: function(){
    this.resetPwdFormWin.close();
    },
    scope: this
    }],
    buttons: [{
    text: 'Change Password',
    iconCls:'icon-disk',
    handler: this.onResetExpiryPwdFormDlgClickOk,
    scope: this
    },{
    text:'Continue Anyway',
    tooltip:'Continue Anyway',
    iconCls:'icon-accept',
    handler: function(){
    this.resetPwdFormWin.close();
    },
    scope: this
    }],
    items:[{
    xtype: 'resetpwdexpiredaysform'
    }]
    });
    this.resetPwdFormWin.show();
    return;
    },

    onResetPwdFormDlgClickOk: function(btn, evt){

    var winform = this.resetPwdFormWin.findByType('resetpasswordform')[0].getForm();
    if (!winform.isValid()) {
    Ext.Msg.alert('Action Status', 'Please enter the value in mandatory field(s).');
    return;
    }

    Ext.Ajax.request({
    url: '/PersonCommand?actionMode=CHANGEPASSWORD',
    method: 'POST',
    params: {'password':winform.findField('password').getValue(),'confirmPassword':winform.findField('confirmPassword').getValue()},
    scope: this,
    success: function(responseObject) {
    this.resetPwdFormWin.close();
    Ext.Notifier.msg('Reset Login Password', "Login password has been updated successfully.");
    },
    failure: function(responseObject) {

    var resobject = Ext.util.JSON.decode(responseObject.responseText);
    var level = 0;
    try {
    level = resobject.level;
    } catch(err){}
    if (level == 601) {
    Ext.MessageBox.alert('Password Error', resobject.errorMsg);
    return;
    }
    if (level == 602) {
    Ext.MessageBox.alert('Password Error', resobject.errorMsg);
    return;
    }
    if (level == 603) {
    Ext.MessageBox.alert('Password Error', resobject.errorMsg);
    return;
    }
    Ext.MessageBox.alert('Information', 'Problem occurred while processing your request.');
    }
    });
    }

    Please suggest me how should i achieve this.

    Thanks in advance,

    Regards,
    Prabhat Kumar

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Prabhat Please post code that is wrapped in code tags in the future.

  3. #3
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    to quickly fix this, set a local reference like this.isCommunication = true *before* your ajax request, and upon success/failure of that async request, clear that flag.

Similar Threads

  1. Replies: 4
    Last Post: 17 Dec 2010, 4:53 AM
  2. Replies: 2
    Last Post: 13 Jul 2010, 7:20 AM
  3. render panel on click of enter button
    By kckc1234 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 17 Sep 2008, 1:44 AM
  4. [SOLVED] EventObject reports wrong xy for click event
    By gutorb4 in forum Ext 1.x: Bugs
    Replies: 5
    Last Post: 5 Sep 2007, 10:30 AM
  5. Enter key while input has focus fires unrelated button click
    By simeon in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 27 Apr 2007, 1:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •