开发者

Select in Opera doesn't close on change event

开发者 https://www.devze.com 2023-04-11 15:14 出处:网络
In Opera (and only in Opera) I have strange behavior of select element. In change event, if I disable this select, it doesn\'t close (collapse).

In Opera (and only in Opera) I have strange behavior of select element. In change event, if I disable this select, it doesn't close (collapse).

    $('select').bind('change', function()
    {
        $(this).attr('disabled', true);
    });

Is it some known issue of opera? 开发者_Go百科So far I haven't found anything.


Setting disabled attribute did not work for me, but this code works:

$('select').change(function() {  
  $(this).hide();
  var _this = this;
  setTimeout(function() {
    $(_this).show();
  }, 1);
});

Just hide select, and after one millisecond show it.


Yes, this is a known bug in Opera (as in the "Opera Software knows about it and is working on a fix, but pretty much nobody else in the world can tell because of Opera's closed bug tracker" meaning of "known"). As far as I remember it may even be fixed for Opera 12 but I haven't double-checked that.

For workarounds, you may want to just leave it since a fix is coming in a future Opera version, using a timeout as suggested earlier should work too.


Use a short delay before disabling the select, 10ms should be sufficient

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号