views:

12

answers:

1

I'm trying to select a text field inside the tab, when the tab is clicked.
The jqueryui event is correctly bound - have tested by putting alerts & by replacing focus() in the below code with hide(). But when I say focus(), it does not focus inside the text field. This is for FF 3.6.10
Code as below -

  $( "#tabs" ).bind( "tabsselect", function(event, ui) {
      console.log("ui.panel: " + ui.panel.id);
      var tabName = ui.panel.id;
      $("#" + tabName).children("#pointContainer").children('#pointSearchPointForm').children("#searchAndPoint").focus();
});

HTML as below -

<div id="tabs-2">
  <DIV id="pointContainer" class="pointContainer">
     <FORM id="pointSearchPointForm" name="pointSearchPointForm" METHOD=POST ACTION="">
        <INPUT size="45" TYPE="text" NAME="searchAndPoint" id="searchAndPoint">
        <INPUT TYPE="button" class="ui-button ui-state-default ui-corner-all" VALUE="Point Select" ONCLICK="someFunction()">
     </FORM>
  </DIV>

A: 

can't you just call $("#searchAndPoint").focus(); ? It's an ID and supposed to be unique. If it's not unique, then that maybe the prblem.

Reigel
The ID is unique, but it doesn't work. The above is a sample code, once it works I'll add logic for the other tabs.
PlanetUnknown
I can't tell, by the looks of your codes, that should be fine. try `setTimeout()` when you trigger `.focus()`, let see if it gets it.
Reigel
Reigel ! Thanks ! That worked. I have tried setTimeOut in similar situations, but it has never worked, especially with IE. But it worked this time 8-)
PlanetUnknown