I've used a pattern like this:

var table = $('table.class')
   .bind('click',selectCell);

function selectCell(e)
{
   var cell = e.target;
   do_something();
}

var cell = table.find('td.eq(8)');
selectCell.apply(table[0],[{target:cell[0]}]);

JK

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Leeoniya
Sent: Friday, November 21, 2008 7:11 PM
To: jQuery (English)
Subject: [jQuery] event delegation - great, but how does one trigger the
handlers through code?


During event delegation, handlers are registered higher in the DOM
tree and then filtered when the event is triggered. This is great if
you have 2000 td/th cells, you can attach a listener to tbody and
filter down. But would i trigger the event programatically? Since the
handler isnt actually registered on the td cells, i cant figure out a
way to do this except maybe construct a fake event with the source
element by hand and pass it into the handler somehow??

this is the biggest drawback to delegation that i have run into, it
would be great to find a good way to manually trigger these events -
if anyone has some advice, please share.

thanks,
Leon

Reply via email to