jQuery问题与更改事件和IE8 [英] jQuery problem with change event and IE8

查看:150
本文介绍了jQuery问题与更改事件和IE8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery 1.4.2中有一个错误,使得在使用DOM事件和jQuery事件时,select-element的更改事件会被触发两次,而这仅在IE7 / 8上。
以下是测试代码:

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事件触摸select元素的选择器上绑定一个实时变化事件也会导致双重触发。

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>

实际错误的票证: http://dev.jquery.com/ticket/6593

这给我们带来了很多麻烦我们的应用程序导致我们使用与jQuery混合的ASP.NET事件,并且一旦在任何元素上连接了一个更改事件,每个选择(下拉列表)就会获得这种双重触发问题。

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版本的最新版本。

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆