12/1/2009 9:44:41 AM
I've been using JQuery for most client side updates these days and one thing has always bothered me. Coding against the change event of a checkbox or radio button in Internet Explorer always waits until you leave the control before firing the event. This can produce incorrect results, especially if you are attempting to tally the number of selected items in a list of checkboxes. Very frustrating...
I finally decided to look into the issue and discovered that it is just the way things are with IE. The code snippet below will force radio buttons to blur and focus again when they are clicked. This leaving of the control and coming back will cause your event to fire correctly. Hopefully IE9 will correct this and we won't need a silly workaround anymore.
$(function() {
if ($.browser.msie) {
$('input:radio').click(function() {
this.blur();
this.focus();
});
}
});
Tags:jquery edb02bd5-e33a-44c9-8433-1d69a06d09da