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
-~----------~----~----~----~------~----~------~--~---

Reply via email to