0 Replies Latest reply on Mar 19, 2012 11:31 AM by J Miller

    Problem using onblur with suggestionBox

    J Miller Newbie

      I have a rich suggestionBox that needs to not only function as a normal suggestion box, but if the user types something quickly and tabs out of the text box before the suggestions appear, it should just save whatever they entered.  I’ve tried doing this a few different ways, but every different way seems to have different bugs that go along with it.  It’s important that it saves when they tab out of the box, because other text fields and suggestionBoxes will be filtered to only include records that align with what was chosen in previous boxes.

       

      I think the ideal solution would be to just call an a4j jsFunction using the onblur event.  The problem with that, is that if you DO wait for the suggestions to appear, clicking on the suggestion box scroll bar triggers the onblur, and it saves the partial match, reRenders the panel and closes the suggestions.  I thought then that if I called a JavaScript function that checked the focus, I could see if the suggestionBox has focus, and if it does, I could do nothing.  If it does not have the focus, then the user has clicked on and I could save it.  Problem is, I can’t figure out how to do that.  I’m using:

       

      document.activeElement.id

       

      to get the ID of the element which has focus.  This works with every text box or button, but the suggestionBox doesn’t appear to have an ID.  I’ve tried specifying an ID on the rich suggestionBox, on the h column that contains the results, and on the outputText for the results.  Each time, the ID I get is empty. 

       

      Anybody have any ideas as to how I can accomplish this?