views:

213

answers:

2

Hi,

I have some code updating a dropdownlist, and then I fire the "change" event manually. It works like it should in firefox, opera and so on, but not in Internet Explorer. Any idea why?

Code attached below.

$(".bringFraktvalgRadio").click(function() {
    var selectedValue = $(".bringFraktvalgRadio:checked").val();
    $("#<%= dropDeliveryOption.ClientID %> option[value=" + selectedValue + "]").attr("selected", true);
    $("#<%= dropDeliveryOption.ClientID %>").trigger("change");
});
A: 

Check out my question and answer to something similar with a checkbox. Check the answer I gave has a link and don't forget to use blur and focus.

Gutzofter
+1  A: 

Sorry, but change event does NOT work as it should in IE (mainly IE6).

1: What you shold do is to set up listener on "click" on select and then trigger "click".

2: Better way to solve it is to add your own event on select. In jQ we do it like this:

$("#yourSelect").bind('myChange',function(){
 //do the chacha
})

And then trigger it like this:

$("#yourSelect").trigger("myChange");
elon