Hi John, Thanks for reply! I was out for while.. (and missed the jquery conf. registration ; (( && :((
Yes you are right. I understood the namespace as object namespace: Type.subtype or Object.property so I assumed that $().trigger('type') would trigger all bound 'type, type.xy, type.xz' - which it does! then I assumed $().unbind('type') would automatically removed all 'type, type.xy, type.xz' which it does not.. (then I got sidetracked by event delegation see ex[2] Event Delegation section -> Bind with Event Delegation and started to look elsewhere...) ex[3] are new tests with the correct assumption event.type. And here is what I found: - there is no way how to trigger only type $().trigger('.type') despite the type can be unbound $().unbind('.type') - despite you can still trigger all bound events - event and event.type by $().trigger('event') , $().unbind('event') treats event and event.type as distinct - event delegation works:) - bind with multiple namespaced events does not work (it seems only the last one fires. I'll retest once it is changed - in 1.3.3?) To sum it up: Bubbling works, .unbind("click") works (but it will not unbind e.g. 'click.two' which is a bit confusing - trigger treats namespaced event as Event.type, bind as 'event.type'), $().trigger('.two') does not trigger type .two - not that useful. Thanks again, Jan Examples (tests are in 3rd section: Event Delegation, Event namespacing, Bubbling...): ex[2] http://www.uicoded.com/test-suite/js/jquery.eventbinder/jquery.eventbinder-test_v0.2.html ex[3] http://www.uicoded.com/test-suite/js/jquery.eventbinder/jquery.eventbinder-test_v0.3.html On Jul 17, 3:28 pm, John Resig <jere...@gmail.com> wrote: > A couple quick points - > > First, it seems like you're using the namespaces backwards. Normally you > would do 'init.collapsable', 'expand.collapsable', etc. (thus you would be > able to remove all the init events in the collapsable namespace, for > example). > > If you could make a demo page demonstrating the bubbling bug, I would > appreciate it. Also a page demonstrating the .unbind("click") bug. > > The last bug you mention has already been filed (and I think we're shooting > for it to land pretty soon):http://dev.jquery.com/ticket/3549 > > --John > > On Fri, Jul 17, 2009 at 1:37 PM, uicoded <uico...@gmail.com> wrote: > > > Bug? (or wrongly assumed functionality) It took me hours to discover > > it. > > > Lets try event delegation with namespaced events.Use Firebug with any > > jQuery page having the h1 (or use other elem). > > > $(document).bind('collapsable.init',function(){ console.log > > ('collapsable.init'); }); > > $(document).bind('collapsable.expand',function(){ console.log > > ('collapsable.expand'); }); > > $(document).bind('collapsable.collapse',function(){ console.log > > ('collapsable.collapse'); }); > > > $('h1').trigger('collapsable.expand'); > > > Works as expected;) Only one event is cought on parent element > > Now try, to bind any event on the same element (h1) and try to trigger > > the same again. > > > $('h1').click(function(){console.log('h1.click')}) > > $('h1').trigger('collapsable.expand'); > > > All three (collapsable.init, collapsable.expand, collapsable.collapse) > > will fire! > > Just as if $('h1').trigger('collapsable'); was called. > > > It seem jQ 1.3.2 does not support namespaced events bubbling. > > > ----------------------------- > > Next issues: > > I naturally thought that if I can trigger all three with the last > > example (trigger('collapsable')) that I can unbind all three with one > > call as well .unbind('collapsable'); which is not the case. > > > Consider: > > $('h1').bind('click.one',function(e){console.log('click.one');}); > > $('h1').bind('click.two',function(e){console.log('click.two');}); > > > I would like to unbind('click') and get rid of all clicks. > > > Lastly, binding multiple namespaced events does not work: > > (does not work in bubbling as well. Here it is bind on the same > > element) > > > $('h1').bind('custom.four custom.five',function(e){console.log > > (e.handler.type);}); > > $('h1').trigger('custom'); //I would expect two events returning > > 'four' and 'five' (only five returns) > > $('h1').trigger('custom.four'); //I would expect 'four' (returns > > nothing) > > > Here tested with common events > > $('h1').bind('click.clk mouseenter.mse',function(e){console.log > > (e.handler.type)); > > what is positive both click and mouseenter will fire, > > mouseenter will return 'mse' and click will return 'mse' as well :( > > > Event delegation has quite few advantages. If you have an experience > > with some limitations (e.g. performance), please share it. > > Event delegation with namespacing would be really nice. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---