Skip to main content

Bug Tracker

Side navigation

#6959 closed bug (wontfix)

Opened August 27, 2010 11:15AM UTC

Closed August 27, 2010 01:16PM UTC

jQuery events aren't asynchronous

Reported by: sharad.banka@gmail.c 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.

Attachments (0)
Change History (1)

Changed August 27, 2010 01:16PM UTC by john comment:1

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).