Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6528 closed bug (worksforme)

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.

Change History (4)

comment:1 Changed 10 years ago by dmethvin

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.

comment:2 Changed 10 years ago by dmethvin

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.

comment:3 Changed 10 years ago by dmethvin

Resolution: worksforme
Status: newclosed

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

comment:4 Changed 10 years ago by eagletsui

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

Note: See TracTickets for help on using tickets.