问题描述
有在jQuery的1.4.2,使得选择元素上改变事件同时使用DOM事件和一个jQuery的事件,而这只有在IE7 / 8的时候被解雇两次的错误。
下面是测试code:
There is a bug in jQuery 1.4.2 that makes change event on select-element getting fired twice when using both DOM-event and a jQuery event, and this only on IE7/8.Here is the test code:
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".myDropDown").change(function() {
});
});
</script>
</head>
<body>
<select class="myDropDown" onchange="alert('hello');">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</body>
</html>
更新:
这个问题的另一种观点,其实这是我们与我们的应用程序的实际问题。在选择器,甚至没有与DOM事件触摸选择元素绑定现场改变事件也造成二次烧成。
Update:Another view of the problem, actually this is the real problem we have with our application. Binding a live change event on a selector that isn't even touching the select-element with DOM-event also causes double firing.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".someSelectThatDoesNotExist").live("change", function() {
});
});
</script>
</head>
<body>
<select class="myDropDown" onchange="alert('hello');">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</body>
</html>
票务实际的错误:
这导致了很多的麻烦我们,我们的应用程序的事业,我们同时使用ASP.NET事件与jQuery混合,一旦挂钩更改事件的任何元素的每个select(下拉列表)上获取此二次烧成的问题。
This causes alot of trouble for us in our application cause we use both ASP.NET-events mixed with jQuery and once you hook up a change event on any element every select (dropdown) gets this double firing problem.
有没有谁知道解决的办法在此期间,直到这个问题是固定的?
Is there anyone who knows a way around this in the meantime until this issue is fixed?
推荐答案
我讨厌提高从死里复活,但jQuery的这个问题最终定格在1.7版本,这个bug并于日前公布。
I hate to raise this question from the dead but jquery finally fixed this bug in version 1.7 which was recently released.
这篇关于jQuery的问题更改事件和IE8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!