Results 1 to 5 of 5

Thread: Error Message when 'Enter' key press

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      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: 'Descripcin',
    		placeHolder: 'Ingrese Descripcin',
    		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
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    Do you still get the error if you comment out the setActiveItem line?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      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
    39,556
    Answers
    3932
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  6. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      0  

    Default

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

Tags for this Thread

Posting Permissions

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