[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-04-01 Thread Ariel Flesler
is it appropriate to use $(this).addClass instead of $(e.target).addClass inside the handler? it seems to work using $(this) but i'm not sure if that's the intended implementation. In most cases, the this and e.target are the same element. They are only different if you set the indexer to be

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-31 Thread Leeoniya
i did the event delegation by hand and it's pretty easy. (tbody).click(myHandler); function myHandler(e) { var e = e || window.event; var elem = e.target || e.srcElement; if (elem.nodeName.toLowerCase() == td) { // do stuff } } however, the jQuery Listen plugin is much more

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-31 Thread Klaus Hartl
On Mar 31, 9:56 am, Leeoniya [EMAIL PROTECTED] wrote: i did the event delegation by hand and it's pretty easy. (tbody).click(myHandler); function myHandler(e) {   var e = e || window.event;   var elem = e.target || e.srcElement;   if (elem.nodeName.toLowerCase() == td) {     // do stuff

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-31 Thread Leeoniya
with the Listen plugin i have something like this: $(tbody).listen(click, td, function(e) { $(this).addClass(edit).html(input type='text' /); $(input, $(this)).each(function() {$(this).focus()}); }) is it appropriate to use $(this).addClass instead of $(e.target).addClass inside the

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-30 Thread Leeoniya
always heard the term, never really explored it; I think i have a lot more refactoring to do now :) Klaus Hartl-4 wrote: I think in this case it is better to use event delegation, e.g. set up a single handler on the parent table element and handle the click here. You can get to the

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-30 Thread pedalpete
Hi Leeoniya, I'm not sure exactly what you are trying to do, but I've got a large table, and when a user clicks on a cell, i pass the id of that cell to a function. No binding, no inline functions. mine works like this, i hope it helps, though it is pretty basic. [code]

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-30 Thread pedalpete
I'm not sure exactly what you are getting at, maybe describing what you are trying to do would help. I have a table that when the user selects certain cells, they are provided with forms, options, moves, etc. (currently being built, so I can't point you to it). Rather than binding to each cell,

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-30 Thread pedalpete
Hey Leeoniya, I'm not sure exactly what you are trying to do, but I think binding each cell to an external function, or creating an 'anonymous' function inline maybe isn't the best way to go. I have a table with lots of cells, and when the user clicks on a cell, i pass the id of that cell to a

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-30 Thread Michael Geary
If you have thousands of td's, that code is going to be very very slow. It makes an array of all the TD elements and then attaches an event handler to every one of them, one by one. You would get *much* better performance by attaching a single event handler to the table itself, then using

[jQuery] Re: bind() and thousands of td elements - inline or extrnal?

2008-03-29 Thread Klaus Hartl
I think in this case it is better to use event delegation, e.g. set up a single handler on the parent table element and handle the click here. You can get to the clicked cell via e.target. --Klaus On Mar 28, 5:25 pm, Leeoniya [EMAIL PROTECTED] wrote: i need to bind a click function to