jQuery syntax for multiple delegated events -


the jquery docs @ http://api.jquery.com/on/ mention benefits of delegated-events using following syntax (which attaches event handler 1 element):

$('#mytable').on('click', 'tr.hoverable', function(){     // blah }); 

but can't find reference proper syntax attaching multiple events @ once delegated-events. there shortcut following, tr.hoverable delegated event?

$('#mytable tr.hoverable').on({     mouseenter: function(){         // blah     },     mouseleave: function(){         // blah     },     click: function(){         // blah     } }); 

or solution ...

$('#mytable').on('click', 'tr.hoverable', function(){     // blah }).on('mouseenter', 'tr.hoverable', function(){     // blah }).on('mouseleave', 'tr.hoverable', function(){     // blah }); 

?

$('#mytable').on({     mouseenter: function(){         // blah     },     mouseleave: function(){         // blah     },     click: function(){         // blah     } }, '.hoverable'); 

as per signature:

.on( events-map [, selector] [, data] )

also, prefer single tagname/classname/id selectors delegation optimized


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -