0 Replies Latest reply on Mar 11, 2008 11:04 AM by Tom Rutsaert

    Losing focus from input field after ajax response

    Tom Rutsaert Newbie

      I have following piece of code

      <a4j:region>
       <h:inputText
       id="City"
       label="City"
       value="#{addressHandler.cityString}"
       required="true"
       onkeypress="return true;">
       <a4j:support
       event="onchange"
       action="#{addressHandler.correctCity()}"
       reRender="streetGroup, cityGroup"
       ajaxSingle="true">
       </a4j:support>
       </h:inputText>
       <rich:suggestionbox
       for="City"
       suggestionAction="#{addressHandler.getCitySuggestions}"
       var="city"
       minChars="2"
       fetchValue="#{city.name}"
       ajaxSingle="true"
       selfRendered="true"
       ignoreDupResponses="true"
       requestDelay="10">
       <h:column>
       <h:outputText value="#{city.name} " />
       </h:column>
       <a4j:support event="onselect"
       action="#{addressHandler.citySelect()}"
       reRender="streetGroup,cityGroup"
       ajaxSingle="true">
       </a4j:support>
       </rich:suggestionbox>
      </a4j:region>
      


      The problem in IE6 is the following.(firefox doesn't have this problem)
      The moment I touch the scroll bar of the suggestion box the onchange event is fired. When the ajax response returns the input field loses focus and because of that the suggestion box should become invisible, this isn't the case. I just get an empty white block under the input field.
      But actually I don't want the suggestionbox to disapear at all. I want that it stays there. Is there a way to keep the suggestionbox open?
      In firefox there is no problem the suggestion box stays open even if I use the scrollbar in the suggestion box.

      The same problem occurs when a user fills in the form and is using the TAB key to go from one input field to another. The moment a certain input field is changed (and it has an <a4j:support event="onchange" /> ), the focus is lost in IE and when the user uses the tab key again the first field gets the focus and not the next field.

      In other words is there a solution that when there is a ajax response in IE the input fields don't lose there focus?

      Or am I overseeing something?