Friday, February 24, 2012

IE 8 and Ajax Support

Recently I came across few bugs related to IE 8, Ajax and JSF.
The main issue was a delay in firing ajax events in IE 8. For example, when user clicked on a radio button, the event did not fire immediately. The event did not get fired on first click. User had to click on radio button and then somewhere else on web page to see the expected result. After spending some time, I found the solution. The solution is using Javascript blur() function,

The blur function is used to remove the focus from the object that it belongs to. Before applying this solution, user had to click somewhere else on webpage to remove the focus from the current object.



Here is the code sample. Write simple Javascript function to blur the object.


Then in html/jsp/xhtml code we call function blurAction on the onclick attribute.

   


The clicked object becomes non-current immediately and we can fire ajax events.