Bug Tracker

Ticket #10878 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

$("select").live("change", function(){ ...broken in IE8 in jQuery 1.7

Reported by: tavelli Owned by: dmethvin
Priority: low Milestone: 1.7.2
Component: event Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

Following example works with 1.6.4, but breaks in 1.7.x

 http://jsfiddle.net/yrA5E/1/

Change History

comment:1 Changed 3 years ago by tavelli

this may have more to do with adding new elements by cloning an existing element with a listener attached?

comment:2 Changed 3 years ago by dmethvin

  • Owner set to tavelli
  • Status changed from new to pending

This seems to work for me in Firefox 8. Is there some specific browser where it failed?

comment:3 Changed 3 years ago by tavelli

  • Status changed from pending to new

Fails in IE8. Haven't tested in IE7 or IE6 yet, will on Monday.

comment:4 Changed 3 years ago by dmethvin

  • Owner changed from tavelli to dmethvin
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to event
  • Milestone changed from None to 1.7.2

I see it now, both the problem and the IE8 in your original title. When the element is cloned it appears the property for _change_attached has been promoted to an attribute and cloned, which means the cloned elements don't receive the event handler patch they need.

comment:5 Changed 3 years ago by tavelli

Do you know of any workaround for this? I tried calling .off() on the select element after its clone and before it is appended back to the page, but no go.

comment:6 Changed 3 years ago by dmethvin

For now the solution is to not clone the element. If you start with a new one it won't incorrectly inherit the attribute that makes it think the event is already attached.

comment:7 Changed 3 years ago by tavelli

The level of hackiness on this is quite high, but calling $("myclonedelement").removeAttr("_change_attached"); after its cloned and before its appended back to the page seems to fix it and work across IE and chrome.

comment:8 Changed 3 years ago by dmethvin

#11033 is a duplicate of this ticket.

comment:9 Changed 3 years ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Fix #10878. Clear oldIE special change/submit flags on a clone.

Changeset: c746f79cc024df41d9300f3b910a8a55b3c91c3e

Note: See TracTickets for help on using tickets.