-
24 Apr 2012 2:52 PM #1
Answered: Error Message when 'Enter' key press
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:
Error: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' }); } } } }
Why happen that?Code:Uncaught TypeError: Cannot call method 'indexOf' of null
Thanks in advance.
-
Best Answer Posted by mitchellsimoens
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') } } } } ] });
-
26 Apr 2012 7:41 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
Do you still get the error if you comment out the setActiveItem line?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
26 Apr 2012 7:46 AM #3
Hi mitchellsimoens, yes i still have it, what else can be?
Thanks for your time.
-
26 Apr 2012 7:59 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
- Answers
- 3111
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 Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
26 Apr 2012 8:13 AM #5
Thank you so much! I'm learning so much with your help.


Reply With Quote