Side navigation
#15157 closed bug (invalid)
Opened June 18, 2014 05:10PM UTC
Closed July 07, 2014 08:56AM UTC
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>
Attachments (0)
Change History (3)
Changed June 18, 2014 05:13PM UTC by comment:1
Changed June 23, 2014 03:37AM UTC by comment:2
owner: | → leolimasa |
---|---|
status: | new → pending |
Feel free to create a test case using jsbin.com or some other online test case environment.
Changed July 07, 2014 08:56AM UTC by comment:3
resolution: | → invalid |
---|---|
status: | pending → closed |
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!
Could not use jsFiddle since it does not support IE8