Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6959 closed bug (wontfix)

jQuery events aren't asynchronous

Reported by: [email protected] Owned by:
Priority: Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: Trigger, asynchronous Cc:
Blocked by: Blocking:

Description

I always thought events should be asynchronous. Turns out jQuery custom events aren't.

<html>

<head>

<script src="jquery.js" type="text/javascript"> </script> <script type="text/javascript">

function foo() {

$(document).bind({

init: function() {

$(document).trigger("process"); document.getElementById("somediv").innerHTML += "hello";

},

process: function() {

for (var i=0; i<10000; ++i) {

document.getElementById("somediv").innerHTML += i.toString();

}

}

} );

} function bar() {

$(document).trigger("init");

}

</script>

</head> <body>

<div id="somediv" style="position: absolute; left: 100px; top:100px; width: 100px; height: 100px;"> </div> <input type="button" onclick="foo();" value="Bind"> <input type="button" onclick="bar();" value="Trigger">

</body> </html>

Click on bind and then click on trigger. In ideal asynchronous events hello should be printed before the numbers. But output is reverse here.

Change History (1)

comment:1 Changed 13 years ago by john

Resolution: wontfix
Status: newclosed

This isn't something that we're going to change - it's up to you to handle any asynchronous behavior or triggering (such as putting the executed code inside a timeout).

Note: See TracTickets for help on using tickets.