Search code examples
jqueryjquery-uifocusjquery-events

Jquery + jqueryui - focusing on text field not working for FireFox


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 Firefox 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>

Solution

  • 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.