Side navigation
#6784 closed bug (wontfix)
Opened July 12, 2010 02:59PM UTC
Closed October 02, 2010 11:16PM UTC
Different behaviour with binding multi eventhandlers pointing to the same function(s) occurs in 1.4.1 and 1.4.2
Reported by: | gillis | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | event | Version: | 1.4.2 |
Keywords: | bind,events | Cc: | |
Blocked by: | Blocking: |
Description
When binding for example 2 event handlers to an element with both bindings pointing to the same function, there is a different behaviour in 1.4.1 and 1.4.2
in 1.4.1 it seems that the second bind is seen as a duplicated and won't be attached to the dom element.
This is exactly what i want.
in 1.4.2 both bind are working.
<div id="test" style="height:200px; height:200px; background-color:red;"> </div>
<script>
function handleClick()
{
console.log('click');
}
jQuery('#test').bind('click',handleClick);
jQuery('#test').bind('click',handleClick);
</script>
clicking on it in 1.4.2 results in two logs,
in 1.4.1 one.
Attachments (0)
Change History (2)
Changed July 21, 2010 12:58AM UTC by comment:1
component: | unfiled → event |
---|
Changed October 02, 2010 11:16PM UTC by comment:2
priority: | → undecided |
---|---|
resolution: | → wontfix |
status: | new → closed |
Please refer to the official jQuery documentation regarding the updates made for the 1.4.2 release with respect to .bind().
URL:http://api.jquery.com/bind/
The below is an example of the behavior you will experience when defining duplicate event handlers, whether using shorthand or the complete write-up of the bind() code needed.
"As of jQuery 1.4.2 duplicate event handlers can be bound to an element instead of being discarded. For example:
function test(){ alert("Hello"); }
$("button").click( test );
$("button").click( test );
The above will generate two alerts when the button is clicked."
Closing ticket as the behavior experienced is something previously agreed upon as being a part of the 1.4.2 jQuery release.