jQuery 1.7.1 ButtonSet in IE8 not consistently firing the change event

岁酱吖の 提交于 2020-01-17 08:02:50

问题


Seeing a problem with a jQuery UI buttonset in IE8 only. Under IE 8, the buttonset does not consistently fire the change event.

<!DOCTYPE html>
<html>
<head>

<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.16/themes/south-street/jquery-ui.css" rel='stylesheet' type='text/css'>

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.11/jquery-ui.js"></script>

<script language="javascript">

    $(document).ready(function () {
        $("#toolGroup").buttonset();
        $("#toolGroup").change(
        function () {
            alert("hi");
        }
        );
    });

</script>
</head>
<body>

    <div id="toolGroup">
        <input name="marker" type="radio" id="check1" value="point" checked /><label for="check1"><img src="/images/point.png" width="40" /></label>
        <input name="marker" type="radio" id="check2" value="line" /><label for="check2"><img src="/images/line.png" width="40" /></label>
        <input name="marker" type="radio" id="check3" value="polygon" /><label for="check3"><img src="/images/polygon.png" width="40" /></label>
    </div>

</body>
</html>

The appearance is mostly fine when it comes up. Everybody is aligned. The button corners are not rounded. When I click on the buttons, they do depress.

But, I can click back and forth a bunch of times and the change event seems to fire randomly. It's totally inconsistent.

Under Chrome, it fires every single time.

Any ideas?

This is a related question on SO. It says to support the click event. I'll try that after I submit this, but that's not the mnemonic that I want. I want "change".


回答1:


Internet Explorer fires the "change" event only when the control loses focus. It's basically broken and useless for a lot of purposes, therefore. Using "click" is really the best alternative.



来源:https://stackoverflow.com/questions/9344663/jquery-1-7-1-buttonset-in-ie8-not-consistently-firing-the-change-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!