Ticket #742 (assigned defect)
IE's attachEvent, FF's addEventListener and Event fire order
| Reported by: | Devign | Owned by: | kamicane |
|---|---|---|---|
| Type: | defect | Priority: | minor |
| Milestone: | Mootools version 1.3 | Component: | Core |
| Keywords: | Events, Event order | Cc: |
Description
IE 6/7 with attachEvent fires event reversed as they were attached. It's a common issue, not related to mootools. However, the Events class can handle it.
<script type="text/javascript">
addEvent("domready",function () {
$("x").addEvent("click",function () { alert("1"); });
$("x").addEvent("click",function () { alert("2"); });
});
</script>
<div id="x">x</div>
FF will alert 1, 2
IE will alert 2, 1
For custom events, it's obviously ok:
<script type="text/javascript">
addEvent("domready",function () {
$("x").addEvent("custom",function () { alert("1"); });
$("x").addEvent("custom",function () { alert("2"); });
$("x").addEvent("click",function () { this.fireEvent("custom"); });
});
</script>
<div id="x">x</div>
alert 1,2 for both browsers.
Though I'm not relying on the event order, it might affect stuff without noticing.
Change History
Note: See
TracTickets for help on using
tickets.