What''s the page.method to change the background color of a DOM element? I''m trying to change the background color of a couple of styled <li>''s when an Ajax link is clicked. Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060807/63de04bf/attachment.html
David, Use Element.addClassName(element, className) and CSS. Hope this helps, Zack On 8/7/06, David R. <lists.david@gmail.com> wrote:> What''s the page.method to change the background color of a DOM element? I''m > trying to change the background color of a couple of styled <li>''s when an > Ajax link is clicked. > > Thanks, > David > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Thanks for the answer, Zack. I''m not sure quite how to use that method, though. Fitting Element.addClassName into an RJS file won''t work, and page.add_class_name"id of element", "class name" throws an error saying AddClassName is not defined. - David On 8/7/06, Zack Chandler <zackchandler@gmail.com> wrote:> > David, > > Use Element.addClassName(element, className) and CSS. > > Hope this helps, > Zack > > On 8/7/06, David R. <lists.david@gmail.com> wrote: > > What''s the page.method to change the background color of a DOM > element? I''m > > trying to change the background color of a couple of styled <li>''s when > an > > Ajax link is clicked. > > > > Thanks, > > David > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060808/b2b9c753/attachment.html
page << "Element.addClassName(element, className)" David R. wrote:> Thanks for the answer, Zack. > > I''m not sure quite how to use that method, though. Fitting > Element.addClassName into an RJS file won''t work, and > page.add_class_name"id of element", "class name" throws an error > saying AddClassName is not > defined. > > - David-- Posted via http://www.ruby-forum.com/.
Try this: page.call ''Element.addClassName'', ''element_id'', ''class_name'' Zack On 8/8/06, David R. <lists.david@gmail.com> wrote:> Thanks for the answer, Zack. > > I''m not sure quite how to use that method, though. Fitting > Element.addClassName into an RJS file won''t work, and page.add_class_name > "id of element", "class name" throws an error saying AddClassName is not > defined. > > - David > > > On 8/7/06, Zack Chandler <zackchandler@gmail.com> wrote: > > David, > > > > Use Element.addClassName(element, className) and CSS. > > > > Hope this helps, > > Zack > > > > On 8/7/06, David R. <lists.david@gmail.com> wrote: > > > What''s the page.method to change the background color of a DOM element? > I''m > > > trying to change the background color of a couple of styled <li>''s when > an > > > Ajax link is clicked. > > > > > > Thanks, > > > David > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
page<<"$(''theElement'').style.background=''red''" also works for me. The $ javascript operator fetches the element with the name of its argument> What''s the page.method to change the background color of a DOM element? > I''m > trying to change the background color of a couple of styled <li>''s when > an > Ajax link is clicked. > > Thanks, > David-- Posted via http://www.ruby-forum.com/.