-
8 Nov 2012 1:53 AM #1
Unanswered: Focus "Next" button in wizard as soon as form details gets filled
Unanswered: Focus "Next" button in wizard as soon as form details gets filled
I am using card layout for wizard, I have put button control at bottom.
Buttons are "Next/Pre/Cancel".
I would like to have Next selected or focus as soon as I filled or complete the form. So I dont have to click manually with mouse. I just need to press enter so that the wizard goes to next step. Here is my code.
buildButtons : function() { return [ { text:'Back', id:'backBtn', hidden:true, autoHeight:true, action: 'Back' }, { text:'Next', id:'nextBtn', autoHeight:true, hidden:false, action: 'Next' }, { text:'Finish', id:'finishBtn', autoHeight:true, hidden:false, // Comments below line if you want finished button on each panel. //hidden:true, action: 'Finish' }, { text:'Cancel', id:'cancelBtn', autoHeight:true, hidden:false, action: 'Cancel' } ];}
-
8 Nov 2012 2:47 AM #2Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Add a key listener to the fields or form wich listens to the enter event. You could use a KeyMap for example.
On keypress you call focus() on the button you want to have focus.
-
8 Nov 2012 5:12 AM #3
If possible please send any Example for same.
-
8 Nov 2012 5:31 AM #4Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
havent tested it but something like this you can pass on to your fieldconfig
or enable keyevents in the config of your fields andCode:{ enableKeyEvents: true, listeners: { keypress: { fn: function(c, e){ if(e.getKey() ==Ext.EventObject.ENTER){ nextButton.focus(); } } } } }
Also an option to set KeyNav on field or formCode:field.on('keypress', function(c, e){ if(e.getKey() ==Ext.EventObject.ENTER){ nextButton.focus(); } } );
Code:var nav = new Ext.KeyNav(field.getEl(), { "enter": { fn: function(e) { nextButton.focus(); }//fn }//left });
-
8 Nov 2012 10:39 PM #5
Instead of enter can I make Next button highlight as soon as user finish entering details in form?
-
10 Nov 2012 6:05 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
Code:new Ext.window.Window({ autoShow : true, width : 400, height : 400, dockedItems : [ { xtype : 'toolbar', dock : 'bottom', items : [ { text : 'Back', action : 'back' }, '->', { text : 'Next', action : 'next', handler : function() { console.log('Next'); } } ] } ], listeners : { afterrender : function(win) { var btn = win.down('button[action=next]'); btn.focus(null, 80); //delay to let DOM settle down } } });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.


Reply With Quote