PDA

View Full Version : Problem with selector/getEls and addClassOnOver



davida
18 Dec 2006, 2:45 PM
I'm have these two lines in my file and the first one is working but the second one seems to have a bug (or I'm not understanding how it should work):


getEls("table.report tr:nth-child(odd)").addClass('alt');
getEls("table.report tr").addClassOnOver('over');


My tables are striped by the "alt" class but the "over" class only affects the very last row in the table when the mouse is over it - and the last row changes no matter which row in the table I'm over! Its like the JS is getting attached to every row correctly but they all are referencing the element of the last table row.

Does anyone see what I'm doing wrong?

jack.slocum
18 Dec 2006, 6:52 PM
There was a note somewhere that if you use "this" + event handlers (like addClassOnOver does under the covers) you have to use the true second param on getEls(). That's because the "this" variable in the event handler will be the shared Element object, which will have a reference to the last dom node it used (not the node it had when the handler was attached). Using true second param solves this reference issue and this can be used like normal.