PDA

View Full Version : Setting focus when tab changes



blomasky
29 Sep 2013, 5:22 PM
When the user selects a new tab, I want to control which field gets focus, but this seems to be harder than I thought it should be. I have logic that looks like this:

onTabPaneTabChange: function (tabpanel, newCard, oldCard, eOpts {


switch (newCard.id) {


case 'inventoryGrid' :
globals.compQuery('#inventoryGrid #searchForm #keyword1').focus();
break;
}
......
But this does not seem to work. Any suggestions please?

Thanks
Bruce

ettavolt
30 Sep 2013, 4:18 AM
Specify delay (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Component-method-focus) param - give the browser a time to finish click processing.

blomasky
30 Sep 2013, 4:50 AM
thanks for the response, but I tried that .focus(true, true) and a long delay .focus(true,500) and the focus still stayed on the Tab. if I press the tab key twice, it will move to the 1st field on the form.

Bruce

ettavolt
30 Sep 2013, 5:02 AM
I'm afraid you need to create a minimal test case, that reproduces the issue. Focus is very unstable thing that is hard to debug - when you switch to dev tool, the page lose focus.