Hi everyone, I recently started using Prototype and think it''s a great library. It makes writing Javascript more fun. :) I wrote some simple code that highlights a table row when a check box in the row is checked. The code works fine in FireFox, but when I tested in IE6, the behavior is strange. In IE6, the first time I click a checkbox, no row gets highlighted. Then when I click the next checkbox, the previous row now gets selected. I have these codes: $(''myForm'').getInputs(''checkbox'', ''items'').each(function(item) { item.observe(''change'', highlightRow); }) My highlightRow function is as follows: function highlightRow(event) { event.element().up(''tr'').toggleClassName(''selectedRow''); //event.findElement(''tr'').toggleClassName(''selectedRow''); } I also tried getting the row using findElement, but same result in IE6. Could someone help me fix the problem? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Titan9999 wrote:> Hi everyone, > > I recently started using Prototype and think it''s a great library. It > makes writing Javascript more fun. :) > > I wrote some simple code that highlights a table row when a check box > in the row is checked. > The code works fine in FireFox, but when I tested in IE6, the behavior > is strange. In IE6, the first time I click a checkbox, no row gets > highlighted. Then when I click the next checkbox, the previous row now > gets selected. > > I have these codes: > > $(''myForm'').getInputs(''checkbox'', ''items'').each(function(item) { > item.observe(''change'', highlightRow); > }) > > My highlightRow function is as follows: > > function highlightRow(event) { > event.element().up(''tr'').toggleClassName(''selectedRow''); > //event.findElement(''tr'').toggleClassName(''selectedRow''); > } > > I also tried getting the row using findElement, but same result in > IE6. > > Could someone help me fix the problem? Thanks. >Try using the ''onclick'' event instead of the ''onchange'' event. IE fires the onchange event in checkboxes only when focus is shifted elsewhere. see http://www.quirksmode.org/dom/events/change.html - Ken Snyder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Ken, That fixed the problem on IE6. Thanks a lot for your help! I hope a future version of Prototype would take care of that problem, so we don''t need to worry about this kind of differences. On May 2, 11:03 am, Ken Snyder <kendsny...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Titan9999 wrote: > > Hi everyone, > > > I recently started using Prototype and think it''s a great library. It > > makes writing Javascript more fun. :) > > > I wrote some simple code that highlights a table row when a check box > > in the row is checked. > > The code works fine in FireFox, but when I tested in IE6, the behavior > > is strange. In IE6, the first time I click a checkbox, no row gets > > highlighted. Then when I click the next checkbox, the previous row now > > gets selected. > > > I have these codes: > > > $(''myForm'').getInputs(''checkbox'', ''items'').each(function(item) { > > item.observe(''change'', highlightRow); > > }) > > > My highlightRow function is as follows: > > > function highlightRow(event) { > > event.element().up(''tr'').toggleClassName(''selectedRow''); > > //event.findElement(''tr'').toggleClassName(''selectedRow''); > > } > > > I also tried getting the row using findElement, but same result in > > IE6. > > > Could someone help me fix the problem? Thanks. > > Try using the ''onclick'' event instead of the ''onchange'' event. IE fires > the onchange event in checkboxes only when focus is shifted elsewhere. > > seehttp://www.quirksmode.org/dom/events/change.html > > - Ken Snyder--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---