x image on a pop up click should focus on textbox but not working as expected

I have a pop up that is generated through gwt code. Upon user click(image x btn), the focus should be set to the textbox. But what I have here is not working as expected. What it does is that It focuses on the textbox but does not close the pop up. I need it to close the pop up first ebfore focuses the textbox. I tried removing the class of the div one by one but it seems that it would not remove the"modal" feature or the page does not respond to any mouse or keyboard click any more. The code below only works as expected if there is an alert("test") before the $('#globalSearchTextBox').focus(); but whenever I remove it, it fails again. It seems that the focus on the "x" image is lost and immediately goes to the globalSearchTextBox even before the pop up is clicked that is why it does not close it and thus still on modal mode. I also tried doing it in the .java code on the xit handler of the image click but still won't work.

I ran out of ideas on how to do this correctly, not a jquery fan too. :( pls help. thanks.

here is my code:

$('#imgExitId').live('keydown', function(e) { 
      var keyCode = e.keyCode || e.which; 

      if (keyCode == 9) { 
        e.preventDefault(); 
        //alert("tab press")
         $('#imgExitId').focus();

      } 
      if (keyCode == 13) { 
          e.preventDefault();
//if alert("test") is added, hen it works 
         $('#globalSearchTextBox').focus();

          } 

    });

I tried hundreds of solution like blur, mouseleave, while, set timeout(i tried delaying the focus coz I thought it was just fast). I even tried removing .css of the pop up panel.

here is the html of the pop up(generated through gwt code):

    <div class="gwt-PopupPanelGlass" style="position: absolute; left: 0px; top: 0px; display: block; width: 1758px; height: 1001px;"></div>
<div style="left: 1156px; top: 39px; position: absolute; overflow: visible;" class="gwt-DecoratedPopupPanel gwt-DecoratedPopupPanel-pnlUserFeedback" id="pnlUserFeedBackId"><div class=""><table cellspacing="0" cellpadding="0" class=""><tbody><tr class="dialogTop"><td class="dialogTopLeft"><div class="dialogTopLeftInner"></div></td><td class="dialogTopCenter"><div class="dialogTopCenterInner"><div class="Caption"></div></div></td><td class="dialogTopRight"><div class="dialogTopRightInner"></div></td></tr><tr class="dialogMiddle"><td class="dialogMiddleLeft"><div class="dialogMiddleLeftInner"></div></td><td class="dialogMiddleCenter"><div class="dialogMiddleCenterInner dialogContent"><div id="pnlUserFeedbackPopupArrowId" class="pnlMainUserFeedback pnlArrow"><img src="images/window-arrow-for-error.gif" class="gwt-Image" title="Error" alt="Error" id="imgUserFeedbackPopupArrowId"><div id="pnlHeaderUserFeedbackPopupId" class="pnlHeaderUserFeedbackPopup"><button type="button" tabindex="0" class="imgExit" title="Close Window" alt="Close Window" id="imgExitId"></button><div class="dataHyperLink lblCloseInUserFeedback" id="lblCloseInUserFeedbackId" style="text-decoration: initial;">close</div><div class="gwt-Label lblHeaderUserFeedbackPopup" id="lblHeaderUserFeedbackPopupId">Error</div><div id="pnlBodyUserFeedbackPopupId" class="pnlBodyUserFeedbackPopup"><div id="pnlMessagePopupId" class="pnlMessagePopup"><img class="gwt-Image imgWarning" title="Warning" alt="Warning" src="images/warning.gif" id="imgWarningId"><div class="gwt-Label lblMessagePopup" id="lblMessagePopupId">Please provide a search term</div></div></div></div></div></div></td><td class="dialogMiddleRight"><div class="dialogMiddleRightInner"></div></td></tr><tr class="dialogBottom"><td class="dialogBottomLeft"><div class="dialogBottomLeftInner"></div></td><td class="dialogBottomCenter"><div class="dialogBottomCenterInner"></div></td><td class="dialogBottomRight"><div class="dialogBottomRightInner"></div></td></tr></tbody></table></div></div>

Answers


Need Your Help

iPhone SDK: Opening TableViewController with Navigation Bar

ios4 uinavigationcontroller viewdidload navigationbar

I'm creating my first iPhone app at the moment and it's going great, though I've come to a bump in the road. I'm trying to open up my settings view (a UITableViewController), though the navigatio...

Troubling pushing to Heroku

ruby-on-rails heroku syntax gemfile

I'm having trouble pushing to Heroku. Have looked around for quite a bit but haven't found a working solution. Seems like there are some missing libraries, the gemfile has sqlite under dev and test...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.