views:

65

answers:

3

I am pretty new to jQuery in general, however the following code works perfectly in Chrome and Firefox, but not in IE8. In IE8, I have to click anywhere on the page to start the animation after selecting a radio button. Here is the code:

$("input[name=method]").change(function() {
    if($("input:radio[name=method]:checked").val() == 'installer') {    
        $('#download').slideUp(0).removeClass("vendorSize").text("Download").addClass("installerSize").slideDown(500);      
    }
    else if($("input:radio[name=method]:checked").val() == 'url') {
        $('#download').slideUp(0).removeClass("installerSize").text("Download From Vendor Website").addClass("vendorSize").slideDown(500);
    }
});

Anyone know why this breaks in IE8 but not in the other browsers? If you feel this would work better using .animate (not that I think it should matter), can you provide an example of how to code it?

Thanks,

Eric R

A: 

Are the inputs showing? In IE, any radio or checkbox inputs that are not showing (i.e. that have display="none") will not throw normal click or change events.

sohtimsso1970
They are all visible (I would provide a link to the page but its behind a login in which I have no control over).
Eric Reynolds
A: 

In IE the change event isn't fired directly when you click the radio button, so you have to click somewhere else before it is fired. You can try using the click event instead of the change event, that should work.

Mattias Jakobsson
Thanks. I swear I had tried to do a click event and it simply broke my entire animation sequence but this definitely worked. Maybe I had a bug in my code before I tried it...
Eric Reynolds
A: 

Some events do not propogate in IE the same as in other browsers. jQuery 1.4 is better than previous versions in this regard. I have had to put .change() in some of my code to propogate change events such as this - force the .change event using the

myselector.trigger('change'); /* we made changes so trigger it */
Mark Schultheiss
Where should the .trigger be placed? I am fairly sure I am using an earlier version of jQuery than 1.4. I inherited this website and am currently adjusting it.
Eric Reynolds