1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default Answered: Error Message when 'Enter' key press

    Hi, i have this textfield and when I press 'Enter' key I get this error message, but still works:

    Code:
    {		xtype: 'textfield',
    		name: 'descripcion',
    		useClearIcon: true,
    		label: 'Descripción',
    		placeHolder: 'Ingrese Descripción',
    		listeners: {
    			keyup: function(thisField, e) {
    				if(e.browserEvent.keyIdentifier == 'Enter'){
    					buscaMatView.setActiveItem('listaMatPanel',{ type: 'slide', direction: 'left' });
    				}
    			}
    		}
    	}
    Error:

    Code:
    Uncaught TypeError: Cannot call method 'indexOf' of null
    Why happen that?

    Thanks in advance.

  2. This is because the form will submit on action (action will be when you hit enter on the field). You should set the submitOnAction config to false:

    Code:
    new Ext.form.FormPanel({
        fullscreen     : true,
        submitOnAction : false,
        items          : [
            {
                xtype       : 'textfield',
                label       : 'Test',
                placeHolder : 'Test',
                listeners   : {
                    keyup : function(field, e) {
                        if (e.browserEvent.keyIdentifier === 'Enter') {
                            console.log('hi')
                        }
                    }
                }
            }
        ]
    });

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,458
    Vote Rating
    1112
    Answers
    3691
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    Do you still get the error if you comment out the setActiveItem line?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default

    Hi mitchellsimoens, yes i still have it, what else can be?
    Thanks for your time.

  5. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,458
    Vote Rating
    1112
    Answers
    3691
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    This is because the form will submit on action (action will be when you hit enter on the field). You should set the submitOnAction config to false:

    Code:
    new Ext.form.FormPanel({
        fullscreen     : true,
        submitOnAction : false,
        items          : [
            {
                xtype       : 'textfield',
                label       : 'Test',
                placeHolder : 'Test',
                listeners   : {
                    keyup : function(field, e) {
                        if (e.browserEvent.keyIdentifier === 'Enter') {
                            console.log('hi')
                        }
                    }
                }
            }
        ]
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default

    Thank you so much! I'm learning so much with your help.

Thread Participants: 1

Tags for this Thread