1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    3
    Vote Rating
    0
    JackTheStriper is on a distinguished road

      0  

    Default Unanswered: ExtJS4 - Ext.dom.Element and fireEvent

    Unanswered: ExtJS4 - Ext.dom.Element and fireEvent


    I'm starting to use ExtJS4, but need some help here...
    I have this HTML code:

    <input type="button" value="Click" id="sendButton">

    <input type="text" id="tbox">
    And this script code:

    Ext.addBehaviors({
    '#sendButton@click': function (){
    alert("Test");
    }
    });


    Ext.get('tbox').on('keydown', function(e){
    if(e.keyCode == Ext.EventObject.ENTER){
    //Ext.select('#sendButton').fireEvent('click');
    //Ext.get('sendButton').fireEvent('click');
    // this is what I need working....
    }
    });
    I just want to, when you press enter on a textbox, it will act like you clicked the button.
    Can anyone help?

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Vote Rating
    115
    Answers
    346
    vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold vietits is a splendid one to behold

      0  

    Default


    Try this:
    Code:
    Ext.addBehaviors({
        '#sendButton@click': function (e, t){
            console.log("Test");
        },
        '#tbox@keydown': function(e, t){
            if(e.keyCode == Ext.EventObject.ENTER){
                Ext.get('sendButton').dom.click();
            }
        }
    });

Thread Participants: 1