#6913 closed bug (fixed)
namespaced event bubbleing wrong
Reported by: | metalculus84 | Owned by: | dmethvin |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | event | Version: | 1.4.3 |
Keywords: | namespace bubbling needsreview | Cc: | |
Blocked by: | Blocking: |
Description (last modified by )
Html code
<div class="parent">
<div class="child1" > </div> <div class="child2"> </div>
</div>
<a class="btn1">customClick.btn1</a> <a class="btn2">customClick.btn2</a>
jQuery code
jQuery('div.child1')
.bind('customClick.btn1', function () {
alert('child1 reacted to customClick.btn1');
});
jQuery('div.child2')
.bind('customClick.btn2', function () {
alert('child2 reacted to customClick.btn2');
});
jQuery('div.parent')
.bind('customClick.btn1', function (e) {
alert('parent reacted to customClick.btn1');
}) .bind('customClick.btn2', function (e) {
alert('parent reacted to customClick.btn2');
});
jQuery('a.btn1')
.click(function(){
jQuery('div.child1').trigger('customClick.btn1');
});
jQuery('a.btn2')
.click(function(){
jQuery('div.child2').trigger('customClick.btn2');
});
When clicking a.btn1, as expected, the customClick.btn1 event is handled by div.child1 and not div.child2. What is not expected is that the 'customClick' event bubbles and triggers the handlers on div.parent for both 'customClick.btn1' and 'customClick.btn2'. Is this right? Is there anyway to have custom events only bubble the event with the namespace that was triggered. In other words, when 'customClick.btn1' is triggered, not all parent handlers for 'customClick' are handled, just ones that handle 'customClick.btn1'
Change History (10)
comment:1 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Owner: | set to metalculus84 |
Priority: | → undecided |
Status: | new → pending |
comment:2 Changed 13 years ago by
Status: | pending → new |
---|
When clicking a.btn1, as expected, the customClick.btn1 event is handled by div.child1 and not div.child2. What is not expected is that the 'customClick' event bubbles and triggers the handlers on div.parent for both 'customClick.btn1' and 'customClick.btn2'. Is this right? Is there anyway to have custom events only bubble the event with the namespace that was triggered. In other words, when 'customClick.btn1' is triggered, not all parent handlers for 'customClick' are handled, just ones that handle 'customClick.btn1'
comment:3 Changed 13 years ago by
Keywords: | bubbling needsreview added; bubbleing removed |
---|---|
Milestone: | 1.4.3 |
Priority: | undecided → high |
Status: | new → open |
Version: | 1.4.2 → 1.4.3 |
comment:5 Changed 12 years ago by
Owner: | changed from metalculus84 to dmethvin |
---|---|
Status: | open → assigned |
comment:6 Changed 12 years ago by
I encountered the same bug. Simple test can be found here: http://jsfiddle.net/RajTa/
comment:7 Changed 12 years ago by
Milestone: | → 1.6 |
---|
comment:8 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed with the 1.6 event reorg.
comment:9 Changed 11 years ago by
This is still not fixed, as of jQuery 1.7.2.
For example:
$('#myelement').on('update.game', myFunc); $.event.trigger('update.global');
myFunc() will fire.
comment:10 Changed 11 years ago by
@mdleichty, works fine with the DOCUMENTED interfaces and proper arguments: http://jsfiddle.net/dmethvin/rAkeb/
jQuery.event.trigger
is not a publicly documented interface, and may change without warning or deprecation.
Could you please provide a live test case at jsFiddle? Thanks.