Skip to main content

Bug Tracker

Side navigation

#6528 closed bug (worksforme)

Opened May 05, 2010 02:15AM UTC

Closed May 05, 2010 03:00AM UTC

Last modified May 05, 2010 04:06PM UTC

Event still trigger after unbind at once

Reported by: eagletsui Owned by:
Priority: Milestone: 1.4.3
Component: event Version: 1.4.2
Keywords: Unbind Cc:
Blocked by: Blocking:
Description

<html>

<head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {

$("#xyz").bind("click" , function() {

$("#xyz").unbind("click");

});

$("#xyz").bind("click" , function() {

alert("bug");

});

});

</script>

</head>

<body>

<input type="button" id ="xyz" value = "click me"/>

</body>

</html>

In jquery 1.3.2 is no problem but 1.4.2 event still trigger.

Attachments (0)
Change History (4)

Changed May 05, 2010 02:52AM UTC by dmethvin comment:1

Note that the "bug" alert appears only once.

I think there may be assumptions here that are not part of jQuery's documented behavior as far as I know:

Event handlers on an element are not guaranteed to be executed in the order they are attached.

Unbinding event handlers *inside* a handler for that event may not prevent a handler from being executed during that event's delivery.

Changed May 05, 2010 02:56AM UTC by dmethvin comment:2

Okay, I did find the documentation here:

http://api.jquery.com/bind/

"If there are multiple handlers registered, they will always execute in the order in which they were bound."

So the remaining issue is with unbinding handlers inside a handler itself.

Changed May 05, 2010 03:00AM UTC by dmethvin comment:3

resolution: → worksforme
status: newclosed

And... calling e.stopImmediatePropagation() takes care of that.

Changed May 05, 2010 04:06PM UTC by eagletsui comment:4

Why this behavior doesn't equal 1.3.2? So many plug-in doesn't work.