views:

397

answers:

3

Hello all,

I have just asked this question an hour ago but with regards to IE8 and I was told that the JQuery Live handlers does not support "change" so I switched over to "click", this solved my problem and now I find Safari does not work with click for some strange reason, anyone know why?

So I was thinking can I just have both?

$('select.htt, select.hst').live('click', function() {
    var channels = parseInt($('#fancy_div select.hst').val(), 10) * parseInt($('#fancy_div select.htt').val(), 10);   
    $('#fancy_div span.yellow2').html(channels + ' Channels');
});

And change(which works on safari)

$('select.htt, select.hst').live('change', function() {
    var channels = parseInt($('#fancy_div select.hst').val(), 10) * parseInt($('#fancy_div select.htt').val(), 10);   
    $('#fancy_div span.yellow2').html(channels + ' Channels');
});

Or is there something more elegant?

EDIT

Maybe I can do a conditional. if ($.browser.msie But how would I do this with the above, the above is also in a $(document).ready(function()

+3  A: 

put it just here

$('select.htt, select.hst').live($.browser.msie?'click':'change', function() { ....
Thanks it a lot for this, helped me out no end. Good idea.
xenon
+1  A: 

It seems you are running into a combination of issues here:

  1. The change event does not bubble in IE, while the click event does
  2. The click event does not fire/buuble on <select>/<option> elements in Safari, while the change event does

I'm not sure of the best way forward for your situation though.

Crescent Fresh
+1  A: 

The change event shouldn't bubble in ANY browser.

I would just have your code re-bind the change handler whenever the menu is added to the DOM, or perhaps even add an onchange attribute to the select if it's generated by a server script.

jarcoal