impact of CSS scope on event observe

1 view
Skip to first unread message

kspar

unread,
Sep 29, 2007, 3:26:04 PM9/29/07
to Ruby on Rails: Spinoffs
Is there a real difference (perf, memory) between observing events
based on the scoping of event handler assignments? For example, if
you're scope is "document" versus "table#people td.employees" when
dealing with a page of 500 rows, is there an advantage to one over the
other? In either case, you dereference the event to get the dom
object you're interested in.

I'm trying some experiments, including seeing if there are different
answers depending on the browser type (especially IE6 vs IE7) and will
post my results if anybody is interested.

Thanks,
David

Prateek

unread,
Sep 29, 2007, 10:20:48 PM9/29/07
to Ruby on Rails: Spinoffs
I think that instead of -
$$("table#people tr td.employee).each(function(item){
Event.observe(item,'click' function(event){
//Your code HERE
});
});


You should -
Event.observe(document.body,'click',function(event){
var target = event.target || event.srcElement;
Element.extend(target);
if(target.hasClassName("employee") === false &&
target.descendantOf("peoeple") === false) return;
//Your code
});

Reply all
Reply to author
Forward
0 new messages