Skip to main content

Bug Tracker

Side navigation

#7794 closed bug (invalid)

Opened December 16, 2010 07:00PM UTC

Closed December 16, 2010 08:23PM UTC

Bug with event handling?

Reported by: Owned by:
Priority: undecided Milestone: 1.6
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


I join you the following example of code. To see what is the problem, just click a few times on the buttons. The browser will very soon be slowing for the "bugged" button, until it does not respond anymore. Tested with Google Chrome and IE9 beta.

<!doctype html>
<html lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<script type="text/javascript" src=""> </script>
	<script type="text/javascript">
		function SslFuncBugged() {
			$("a.sslgoogle-bugged").attr("href", "");
			$("a.sslgoogle-bugged").text(" over SSL");
			$("#ssl-button-bugged").text("Ungo SSL... (bugged)");
		function NoSslFuncBugged() {
			$("a.sslgoogle-bugged").attr("href", "");

			$("#ssl-button-bugged").text("Go SSL! (bugged)");
		function SslFunc() {
			$("a.sslgoogle").attr("href", "");
			$("a.sslgoogle").text(" (SSL)");
			document.getElementById("ssl-button").innerHTML = "UnGo SSL...";
			document.getElementById("ssl-button").onclick = NoSslFunc;
		function NoSslFunc() {
			$("a.sslgoogle").attr("href", "");

			document.getElementById("ssl-button").innerHTML = "Go SSL!";
			document.getElementById("ssl-button").onclick = SslFunc;

		$(document).ready(function() {
		<a class="sslgoogle" href=""></a>
		<button id="ssl-button">Go SSL!</button>
		<a class="sslgoogle-bugged" href=""></a>
		<button id="ssl-button-bugged">Go SSL! (bugged)</button>

What seems to cause problems is the assignation of the event handler for the click event of the button.

Attachments (0)
Change History (3)

Changed December 16, 2010 07:36PM UTC by ajpiano comment:1

owner: →
status: newpending

It is not clear at all what the actual "problem" is here, aside from the fact that if you keep on adding lots of event handlers on every event, the speed of execution will gradually become slower and slower. That is not a jQuery problem, but a problem for your application.

I cannot fathom a usecase in which it would be necessary to have two handlers, the first of which rebinds the second on every click, and the second of which rebinds the first on every click.

If you can provide any evidence of an actual, bona-fide jQuery bug, then we'll be happy to investigate this issue further. If your concern is an amorphous, "my code slows down when i add a boatload of event handlers recursively," then there is little we can do to assist.

Changed December 16, 2010 08:16PM UTC by comment:2

status: pendingnew

Ok, my mistake.

Seems like I missed my chance to read the f... manual, so I could have seen that since v1.4.2 jQuery enables me to add several events to one object, and that .unbind() was the solution to my "problem". My misunderstanding was due to my thinking .bind() would reassign the handler every time I would call it, and not enqueue them. This is what I wanted to show with the example of code I gave, which was not a real application.

Sorry for that, you can change the status of this ticket to "newbie waste of time".

Changed December 16, 2010 08:23PM UTC by ajpiano comment:3

resolution: → invalid
status: newclosed

Heh, since that's not an available status, I'm gonna go with 'invalid' instead :) Thanks for your time and interest in helping jQuery!