Bug Tracker

Opened 5 years ago

Closed 5 years ago

#15157 closed bug (invalid)

IE8 only: "this" binding being associated to the wrong element when the event callback is executed

Reported by: leolimasa Owned by: leolimasa
Priority: undecided Milestone: None
Component: event Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:

Description

The “this” reference is not being set correctly to the element that has fired the event, when using any of the jQuery event attaching functions and the html was manipulated without jquery before.

The following HTML code will reproduce the issue when executed in IE8 or in IE8 mode: <html>

<body>

<script src="mpage-jquery/src/main/resources/util/js/jquery/jquery-1.11.1.js"></script>

<div id="outsider">click me</div>

<div id="contents"> <div id="mydiv1">div1</div>

</div>

<script language="javascript">

Generates ids $("#mydiv1").click(function() { alert("I am: " + this.id); });

perform click to force the div into the cache $("#mydiv1").click();

"reload" the contents and reatach events var html = document.getElementById("contents").innerHTML; $("#contents").html(html); $("#mydiv1").click(function() { alert("I am: " + this.id); });

$("#outsider").click(function() { alert("Outsider ID: " + this.id); });

this will fire the outsider function with the context of mydiv1, due to cache issues on ie8 $("#outsider").click();

</script>

</body> </html>

Change History (3)

comment:1 Changed 5 years ago by leolimasa

Could not use jsFiddle since it does not support IE8

comment:2 Changed 5 years ago by dmethvin

Owner: set to leolimasa
Status: newpending

Feel free to create a test case using jsbin.com or some other online test case environment.

comment:3 Changed 5 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.